forked from ARMmbed/mbed-simulator
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
build-demos.js
42 lines (35 loc) · 1.04 KB
/
build-demos.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
const child_process = require('child_process');
const program = require('commander');
const fs = require('fs');
const demo_output_directory = 'out';
function buildDemo(root_demos_directory, demo_directory) {
console.log(`Building ${demo_directory}...`);
const buildResult = child_process.spawnSync(
'node',
[
'cli.js',
'-v',
'-i',
`${root_demos_directory}/${demo_directory}`,
'-o',
demo_output_directory,
'--compiler-opts',
'-O2'
]
);
if (buildResult.status === 0) {
console.log(buildResult.stdout.toString());
} else {
console.log(buildResult.stderr.toString());
}
}
program.option(
'-i --input-dir <dir>', 'Input directory for the demos', 'demos'
);
program.parse(process.argv);
if (!fs.existsSync(demo_output_directory)) {
fs.mkdirSync(demo_output_directory);
}
fs.readdir(program.inputDir, (err, directories) => directories.map(
directory => buildDemo(program.inputDir, directory)
));