-
Notifications
You must be signed in to change notification settings - Fork 0
/
all.js
27 lines (23 loc) · 953 Bytes
/
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
const fs = require('fs');
const spawn = require('cross-spawn');
const serial = require('promise-serial');
const ignored = ['node_modules', '.git', 'example'];
const dirs = fs.readdirSync(__dirname).filter(f => ignored.indexOf(f) === -1 && fs.statSync(`${__dirname}/${f}`).isDirectory());
const subCommands = dirs.map((dirname, idx) => () => new Promise((resolve, reject) => {
try {
console.log(`running ${process.argv.slice(3).join(' ')} on ${dirname}`)
process.chdir(idx > 0 ? `../${dirname}` : dirname);
const start = spawn(process.argv[3], process.argv.slice(4), { stdio: 'inherit' });
start.on('close', (code) => {
console.log(`child process for ${dirname} exited with code ${code}`);
resolve();
});
if(process.argv[2] === 'parallely') {
resolve();
}
}
catch(e) {
reject(e);
}
}));
serial(subCommands).catch(e => console.log(e));