forked from kolodny/safetest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
29 lines (27 loc) · 927 Bytes
/
build.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
const fs = require('fs');
const { spawnSync } = require('child_process');
try {
fs.mkdirSync('build');
} catch (e) {}
const examples = fs.readdirSync('examples');
const dirs = [];
for (const example of examples) {
const cwd = `examples/${example}`;
const stat = fs.statSync(cwd);
if (stat.isDirectory()) {
dirs.push(example);
console.log(`running build for examples/${example}`);
spawnSync('npm', ['install'], { cwd, stdio: 'inherit' });
spawnSync('npm', ['run', 'build'], { cwd, stdio: 'inherit' });
}
}
fs.writeFileSync(
'build/index.html',
`<style>table,td,th{border:1px solid;border-collapse:collapse;padding:8px}</style><table><tr><th>App</th><th>Artifacts</tr>` +
dirs
.map(
(dir) =>
`<td><a href="${dir}">${dir} App</a></td><td><a href="/report.html#results=${dir}/artifacts/results.json&url=${dir}/">${dir} Artifacts</a>`
)
.join('</tr></tr>')
);