-
Notifications
You must be signed in to change notification settings - Fork 36
/
setup.js
58 lines (35 loc) · 1.8 KB
/
setup.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
47
48
49
50
51
52
53
54
55
56
57
58
var fs = require('fs');
var resolve = require('path').resolve;
var join = require('path').join;
var cp = require('child_process');
var os = require('os');
// get library path
var root = resolve(__dirname, '.');
// npm binary based on OS
var npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm';
fs.readdirSync(root).forEach(function (subDir) {
var subDirPath = join(root, subDir);
// ensure path has package.json --> skip backend folder
if (!fs.existsSync(join(subDirPath, 'package.json'))) return;
console.log('===================================================================');
console.log(`Performing "npm install" inside ${subDir} folder`);
console.log('===================================================================');
// install dependencies
cp.spawnSync(npmCmd, ['ci'], { env: process.env, cwd: subDirPath, stdio: 'inherit' });
// build if needed
if (subDir === 'host-app' || subDir === 'backend') return;
console.log('===================================================================');
console.log(`Build app inside ${subDir} folder`);
console.log('===================================================================');
cp.spawnSync(npmCmd, ['run', 'build:local'], { env: process.env, cwd: subDirPath, stdio: 'inherit' });
});
// Running the app
console.log('===================================================================');
console.log(`Starting the json-server and the app`);
console.log('===================================================================');
// backend
var backendPath = resolve(__dirname, './backend');
cp.spawn(npmCmd, ['start'], { env: process.env, cwd: backendPath, stdio: 'inherit' });
// host-app
var hostAppPath = resolve(__dirname, './host-app');
cp.spawn(npmCmd, ['start'], { env: process.env, cwd: hostAppPath, stdio: 'inherit' });