st-bundle
Version:
CLI for watching and bundling SpringType projects.
33 lines (32 loc) • 970 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const env_1 = require("../env");
async function tsc(opts, target) {
let tscOptions = [];
for (const key in opts) {
if (opts[key] !== undefined) {
if (key === 'watch') {
tscOptions.push(`--${key}`);
}
else {
tscOptions.push(`--${key}`, String(opts[key]));
}
}
}
if (target) {
tscOptions.push(target);
}
return new Promise((resolve, reject) => {
const proc = child_process_1.spawn('tsc' + (/^win/.test(process.platform) ? '.cmd' : ''), tscOptions, {
cwd: env_1.env.SCRIPT_PATH,
});
proc.on('close', function (code) {
if (code === 8) {
return reject('Error detected');
}
return resolve();
});
});
}
exports.tsc = tsc;