@keymanapp/kmc
Version:
Keyman Developer compiler command line tools
31 lines • 1.06 kB
JavaScript
import * as fs from 'fs';
import * as path from 'path';
import { InfrastructureMessages } from '../../messages/infrastructureMessages.js';
export class BuildActivity {
async runCompiler(compiler, infile, outfile, callbacks, options) {
if (!await compiler.init(callbacks, options)) {
return false;
}
const result = await compiler.run(infile, outfile);
if (!result) {
return false;
}
if (!this.createOutputFolder(outfile ?? infile, callbacks)) {
return false;
}
return await compiler.write(result.artifacts);
}
createOutputFolder(targetFilename, callbacks) {
const targetFolder = path.dirname(targetFilename);
try {
fs.mkdirSync(targetFolder, { recursive: true });
}
catch (e) {
callbacks.reportMessage(InfrastructureMessages.Error_CannotCreateFolder({ folderName: targetFolder, e }));
return false;
}
return true;
}
}
;
//# sourceMappingURL=BuildActivity.js.map