Vehicle energy consumption and production simulator
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

37 lines
1.1 KiB

let child_process = require('child_process');
let fs = require('fs');
let toolsDir = __dirname;
let srcDir = toolsDir + "/../src";
let intermediateDir = toolsDir + "/../.intermediate";
let nodeModulesDir = toolsDir + "/../node_modules";
if (!fs.existsSync(intermediateDir)){
fs.mkdirSync(intermediateDir);
}
if (!fs.existsSync(intermediateDir+'/app')){
fs.mkdirSync(intermediateDir+'/app');
}
let commands = [
() => child_process.fork(toolsDir + '/purify.js', {'cwd': srcDir}),
() => child_process.fork(toolsDir + '/embed.js'),
() => child_process.fork(nodeModulesDir + '/typescript/lib/tsc.js', {'cwd': srcDir+'/app'}),
() => child_process.fork(toolsDir + '/embed-app.js'),
() => child_process.fork(nodeModulesDir + '/typescript/lib/tsc.js', {'cwd': srcDir})
];
let commandIdx = 0;
function executeCommand(commandIdx) {
let process = commands[commandIdx]();
process.on('close', (exitCode) => {
if(exitCode != 0) throw "Command " + commands[commandIdx] + " failed with code " + exitCode;
commandIdx += 1;
if(commandIdx == commands.length) return;
executeCommand(commandIdx);
});
}
executeCommand(commandIdx);