spiegel-keyman/developer/js/source/kmlmc.ts
Marc Durdin 65c8c89be5 chore(web): adapts keyman-version bundling in Developer products
As KEYMAN-VERSION changed from being a type to a class, this broke the
bundling and referencing strategies in Developer/Server and
Developer/kmlmc. This updates the bundling process and fixes the
references in both projects.

Note that keyman-version no longer depends on gosh. Given we are
currently manually calling the build for this in all projects (or should
be!), it's better that we keep the build of this explicit for now.

If we want to restore the postinstall/postci steps in the future, the
gosh dependency would need to be manually removed from package.json in
order for the bundling builds to work for Developer/Server and
Developer/kmlmc.
2022-05-28 10:57:24 +10:00

47 lines
No EOL
1.1 KiB
JavaScript

#!/usr/bin/env node
/**
* kmlmc - Keyman Lexical Model Compiler
*/
/// <reference path="lexical-model-compiler/lexical-model.ts" />
import * as fs from 'fs';
import * as program from 'commander';
import { compileModel } from './util/util';
import { SysExits } from './util/sysexits';
let inputFilename: string;
const KEYMAN_VERSION = require("@keymanapp/keyman-version").KEYMAN_VERSION;
/* Arguments */
program
.description('Compiles Keyman lexical models')
.version(KEYMAN_VERSION.VERSION_WITH_TAG)
.arguments('<infile>')
.action(infile => inputFilename = infile)
.option('-o, --outFile <filename>', 'where to save the resultant file');
program.parse(process.argv);
// Deal with input arguments:
if (!inputFilename) {
exitDueToUsageError('Must provide a lexical model source file.');
}
// Compile:
let code = compileModel(inputFilename);
// Output:
if (program.outFile) {
fs.writeFileSync(program.outFile, code, 'utf8');
} else {
console.log(code);
}
function exitDueToUsageError(message: string): never {
console.error(`${program._name}: ${message}`);
console.error();
program.outputHelp();
return process.exit(SysExits.EX_USAGE);
}