-
Notifications
You must be signed in to change notification settings - Fork 12
/
buildAll.js
39 lines (34 loc) · 1.09 KB
/
buildAll.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
/**
* Adapted from redux
* Runs an ordered set of commands within each of the build directories.
*/
import fs from 'fs';
import path from 'path';
import { spawnSync } from 'child_process';
var exampleDirs= fs.readdirSync(__dirname).filter(file =>
fs.statSync(path.join(__dirname, file)).isDirectory());
// Ordering is important here. `npm install` must come first.
var cmdArgs = [
{ cmd: 'yarn', args: ['--no-lockfile'] },
];
exampleDirs.shift(); // remove .git dir
//console.log('example dirs: ', exampleDirs);
for (const dir of exampleDirs) {
for (const cmdArg of cmdArgs) {
// declare opts in this scope to avoid https://github.com/joyent/node/issues/9158
const opts = {
cwd: path.join(__dirname, dir),
stdio: 'inherit'
};
process.stdout.write(`${opts.cwd}\n`);
let result = {};
if (process.platform === 'win32') {
result = spawnSync(`${cmdArg.cmd}.cmd`, cmdArg.args, opts);
} else {
result = spawnSync(cmdArg.cmd, cmdArg.args, opts);
}
if (result.status !== 0) {
throw new Error('Building examples exited with non-zero');
}
}
}