-
Notifications
You must be signed in to change notification settings - Fork 133
/
dev.js
46 lines (38 loc) · 1.29 KB
/
dev.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
42
43
44
45
46
const execSync = require('child_process').execSync;
const spaw = require('child_process').spawn;
const fs = require('fs');
(async () => {
await execSync(`yarn`, { stdio: 'inherit', shell: true });
const buildAndWatch = async (folder, skipWatch = false) => {
const log = (message) => console.log(`${folder}: ${message}`);
if (skipWatch) {
log('skip watch project')
return;
}
if (!fs.existsSync(folder + '/dist/')) {
await execSync(`yarn build --cwd ${folder}`, { stdio: 'inherit', shell: true });
}
await new Promise((resolve) => {
log('Watching changes...');
const child = spaw('yarn', ['--cwd', folder, 'dev'], { shell: true });
child.stdout.on('data', log);
child.stderr.on('data', log);
child.on('close', (code) => {
resolve(code)
});
});
}
console.log('Building and watching...');
await Promise.all([
"interfaces",
"common",
"logger-service",
"frontend",
"auth-service",
"guardian-service",
"api-gateway",
"mrv-sender",
"ipfs-client",
"topic-viewer"
].map(project => buildAndWatch(project, project === "frontend")));
})();