forked from krausest/js-framework-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild-single.js
52 lines (40 loc) · 1.58 KB
/
rebuild-single.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
const { execSync } = require("child_process");
const args = process.argv.slice(2);
const argsString = args.join(" ");
// Use npm ci or npm install ?
const ci = args.includes("--ci");
// Copy package-lock back for docker build or build locally?
const docker = args.includes("--docker");
const frameworks = args.filter((a) => !a.startsWith("--"));
console.log("args", args, "ci", ci, "docker", docker, "frameworks", frameworks);
/*
rebuild-single.js [--ci] [--docker] [keyed/framework1 ... non-keyed/frameworkN]
This script rebuilds a single framework
By default it rebuilds from scratch, deletes all package.json and package-lock.json files
and invokes npm install and npm run build-prod for the benchmark
With argument --ci it rebuilds using the package-lock.json dependencies, i.e.
it calls npm ci and npm run build-prod for the benchmark
Pass list of frameworks
*/
try {
if (frameworks.length == 0) {
console.log(
"ERROR: Missing arguments. Command: docker-rebuild keyed/framework1 non-keyed/framework2 ..."
);
process.exit(1);
}
const buildCmd = docker
? `docker exec -it js-framework-benchmark cp /src/rebuild-build-single.js /build/ && docker exec -it js-framework-benchmark node rebuild-build-single.js ${argsString}`
: `node rebuild-build-single.js ${argsString}`;
console.log(buildCmd);
execSync(buildCmd, {
stdio: "inherit",
});
const checkCmd = `node rebuild-check-single.js ${argsString}`;
console.log(checkCmd);
execSync(checkCmd, {
stdio: "inherit",
});
} catch (e) {
console.log(`ERROR: Rebuilding ${argsString} was not successful`);
}