UNPKG

696 BJavaScriptView Raw
1const fs = require('fs');
2const { resolve, join } = require('path');
3const cp = require('child_process');
4const os = require('os');
5
6// get packages path
7const lib = resolve(__dirname, './packages/');
8
9fs.readdirSync(lib)
10 .forEach((mod) => {
11 const modPath = join(lib, mod);
12 // ensure path has package.json
13 if (!fs.existsSync(join(modPath, 'package.json'))) return;
14
15 // npm binary based on OS
16 const npmCmd = os.platform().startsWith('win') ? 'npm.cmd' : 'npm';
17
18 // Install folder
19 cp.spawnSync(npmCmd, ['i'], { env: process.env, cwd: modPath, stdio: 'inherit' });
20 cp.spawnSync(npmCmd, ['run', 'build'], { env: process.env, cwd: modPath, stdio: 'inherit' });
21 });