@keymanapp/kmc
Version:
Keyman Developer compiler command line tools
51 lines (49 loc) • 2 kB
JavaScript
/**
* kmlmp - Keyman Lexical Model Package Compiler
*/
// Note: this is a deprecated package and will be removed in Keyman 18.0
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e296a283-e059-596f-8866-5b3965557b46")}catch(e){}}();
import { Command } from 'commander';
import { KmpCompiler } from '@keymanapp/kmc-package';
import KEYMAN_VERSION from "@keymanapp/keyman-version";
import { NodeCompilerCallbacks } from './util/NodeCompilerCallbacks.js';
let inputFilename;
const program = new Command();
/* Arguments */
program
.description('Compiles Keyman lexical model packages\nDeprecated: use <kmc build> instead; will be removed in v18')
.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 package source file.');
}
let outputFilename = program.opts().outFile ? program.opts().outFile : inputFilename.replace(/\.kps$/, ".kmp");
//
// Run the compiler
//
const callbacks = new NodeCompilerCallbacks({ logLevel: 'info' });
let kmpCompiler = new KmpCompiler();
if (!await kmpCompiler.init(callbacks, null)) {
process.exit(1);
}
let result = await kmpCompiler.run(inputFilename, outputFilename);
if (!result) {
process.exit(1);
}
if (!await kmpCompiler.write(result.artifacts)) {
console.error('Failed to write kmp file');
process.exit(1);
}
function exitDueToUsageError(message) {
console.error(`${program.name()}: ${message}`);
console.error();
program.outputHelp();
return process.exit(64 /* SysExits.EX_USAGE */);
}
//# sourceMappingURL=kmlmp.js.map
//# debugId=e296a283-e059-596f-8866-5b3965557b46