@keymanapp/kmc
Version:
Keyman Developer compiler command line tools
35 lines • 1.54 kB
JavaScript
import * as path from 'path';
import { platform } from 'os';
import { KmnCompiler } from '@keymanapp/kmc-kmn';
import { BuildActivity } from './BuildActivity.js';
export class BuildKmnKeyboard extends BuildActivity {
get name() { return 'Keyman keyboard'; }
get sourceExtension() { return ".kmn" /* KeymanFileTypes.Source.KeymanKeyboard */; }
get compiledExtension() { return ".kmx" /* KeymanFileTypes.Binary.Keyboard */; }
get description() { return 'Build a Keyman keyboard'; }
async build(infile, outfile, callbacks, options) {
// We need to resolve paths to absolute paths before calling kmc-kmn
infile = getPosixAbsolutePath(infile);
if (outfile) {
outfile = getPosixAbsolutePath(outfile);
}
const compiler = new KmnCompiler();
return await super.runCompiler(compiler, infile, outfile, callbacks, options);
}
}
function getPosixAbsolutePath(filename) {
if (platform() == 'win32') {
// On Win32, we need to use backslashes for path.resolve to work
filename = filename.replace(/\//g, '\\');
}
// Resolve to a fully qualified absolute path
filename = path.resolve(filename);
if (platform() == 'win32') {
// Ensure that we convert the result back to posix-style paths which is what
// kmc-kmn expects. On posix platforms, we assume paths have forward slashes
// already
filename = filename.replace(/\\/g, '/');
}
return filename;
}
//# sourceMappingURL=BuildKmnKeyboard.js.map