forked from reduxjs/react-redux-benchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetupRuns.js
78 lines (67 loc) · 1.95 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
/* 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('npm', ['install'], {
cwd: __dirname,
stdio: 'inherit',
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
installTask = spawn.sync('npm', ['install'], {
cwd: join(__dirname, 'fps-emit'),
stdio: 'inherit',
})
if (installTask.status > 0) {
process.exit(installTask.status);
}
installTask = spawn.sync('npm', ['run', '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('npm', ['install'], {
cwd,
stdio: 'inherit',
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
copyFile(join(__dirname, 'copy-to-public', 'react.production.min.js'), join(src, 'public', 'react.production.min.js'), e => {
if (e) {
console.log(e)
process.exit(1);
}
})
copyFile(join(__dirname, 'copy-to-public', 'redux.min.js'), join(src, 'public', 'redux.min.js'), e => {
if (e) {
console.log(e)
process.exit(1);
}
})
console.log(`building production version of benchmark ${benchmark}...`)
installTask = spawn.sync('npm', ['run', 'build'], {
cwd,
stdio: 'inherit',
});
if (installTask.status > 0) {
process.exit(installTask.status);
}
const dest = join(__dirname, 'runs', benchmark);
copy(join(src, 'build'), dest);
})