forked from namecheap/ilc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
start_all.js
41 lines (35 loc) · 1.21 KB
/
start_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
31
32
33
34
35
36
37
38
39
40
41
const concurrently = require('concurrently');
const childProcess = require('child_process');
let runWithApps = true;
let noWatch = false;
const myCmd = process.argv.slice(2).join(' ').trim();
if (myCmd.includes('--no-apps')) {
runWithApps = false;
}
if (myCmd.includes('--no-watch')) {
noWatch = true;
}
const commands = [
{ command: `cd ./ilc/ && ${noWatch ? 'npx cross-env NODE_ENV=production' : ''} npm run ${noWatch ? 'start' : 'dev'}`, name: 'ilc' },
{ command: `cd ./registry/ && npm run ${noWatch ? 'start' : 'dev'}`, name: 'registry' },
];
if (!noWatch) {
commands.push({ command: 'cd ./registry/client && npm run build:watch', name: 'registry:ui' });
}
if (runWithApps) {
commands.push({ command: 'docker run --rm --name ilc-demo-apps -p 8234-8240:8234-8240 namecheap/ilc-demo-apps', name: 'demo-apps' });
}
process.on('exit', () => {
childProcess.execSync('docker stop ilc-demo-apps');
})
concurrently(commands, {
prefix: 'name',
killOthers: ['failure', 'success'],
}).result.then(() => {
console.log('concurrently was finished successfully');
process.exit(0);
}, (err) => {
console.error('concurrently was finished with error');
console.error(err);
process.exit(1);
});