forked from reduxjs/react-redux-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupRuns.js
82 lines (72 loc) · 1.93 KB
/
setupRuns.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* eslint no-console: 0 */
"use strict";
const { readdirSync, copyFile } = require("fs");
const rimraf = require("rimraf");
const { join } = require("path");
const spawn = require("cross-spawn");
const copy = require("recursive-copy");
console.log("clearing out old runs...");
rimraf.sync(join(__dirname, "runs", "*"));
console.log(`installing global dependencies of all benchmarks...`);
let installTask = spawn.sync("yarn", [""], {
cwd: __dirname,
stdio: "inherit"
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
installTask = spawn.sync("yarn", [""], {
cwd: join(__dirname, "fps-emit"),
stdio: "inherit"
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
installTask = spawn.sync("yarn", ["build"], {
cwd: join(__dirname, "fps-emit"),
stdio: "inherit"
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
const sources = readdirSync(join(__dirname, "sources"));
sources.forEach(benchmark => {
const src = join(__dirname, "sources", benchmark);
let cwd;
cwd = src;
console.log(`installing dependencies of benchmark ${benchmark}...`);
let installTask = spawn.sync("yarn", [""], {
cwd,
stdio: "inherit"
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
const filesToCopy = [
"react.production.min.js",
"react-dom.production.min.js",
"redux.min.js"
];
filesToCopy.forEach(filename => {
copyFile(
join(__dirname, "copy-to-public", filename),
join(src, "public", filename),
e => {
if (e) {
console.log(e);
process.exit(1);
}
}
);
});
console.log(`building production version of benchmark ${benchmark}...`);
installTask = spawn.sync("yarn", ["build"], {
cwd,
stdio: "inherit"
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
const dest = join(__dirname, "runs", benchmark);
copy(join(src, "build"), dest);
});