-
Notifications
You must be signed in to change notification settings - Fork 8
/
run_all.js
30 lines (25 loc) · 951 Bytes
/
run_all.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const fs = require('fs');
const spawnSync = require('child_process').spawnSync;
const myCmd = process.argv.slice(2).join(' ');
if (myCmd === '') {
console.error(`Please specify command to run, example: node run_all.js npm i`);
return;
}
const commands = [];
fs.readdirSync('./apps').forEach(fileName => {
const stat = fs.lstatSync(`./apps/${fileName}`);
if (stat.isFile()) {
return;
}
commands.push({ command: `cd ./apps/${fileName}/ && ${myCmd}`, name: fileName });
});
commands.forEach(cmd => {
console.log('');
console.log('');
console.log(`Executing command for "${cmd.name}"... Calling: ${cmd.command}`);
console.log('');
const res = spawnSync(cmd.command, {shell: true, timeout: 120000, killSignal: 'SIGKILL', stdio: 'inherit'});
if (res.status !== 0) {
throw new Error(`Error during command "${cmd.command}" execution. Exited with non-zero code "${res.status}".`);
}
});