forked from krausest/js-framework-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
71 lines (60 loc) · 2.29 KB
/
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
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
var _ = require('lodash');
var exec = require('child_process').execSync;
var fs = require('fs');
var path = require('path');
var yargs = require('yargs');
let args = yargs(process.argv)
.usage("npm run build [-- [--check] [--skipIrrelevant] [--restartWith] [--benchmarks_only]]")
.help('help')
.boolean('check')
.boolean('benchmarks_only')
.boolean('skipIrrelevant')
.string('restartWith')
.argv;
var referenceBranch = "origin/master";
var restartWithFramework = args.restartWith || '';
var core = args.benchmarks_only ? [] : ["webdriver-ts", "webdriver-ts-results"].map(f => ["", f]);
var frameworks = [].concat(
fs.readdirSync('./frameworks/keyed').map(f => ['frameworks/keyed/', f]),
fs.readdirSync('./frameworks/non-keyed').map(f => ['frameworks/non-keyed/', f]));
var notRestarter = ([_, name]) => !name.startsWith(restartWithFramework || undefined);
var [skippable, buildable] = !restartWithFramework
? [[],
frameworks]
: [_.takeWhile(frameworks, notRestarter),
_.dropWhile(frameworks, notRestarter)];
var relevant = args.skipIrrelevant && !_.some(core, isDifferent)
? _.filter(buildable, isDifferent)
: buildable;
_.each(skippable, ([dir,name]) => console.log("*** Skipping " + dir + name));
_.each([].concat(relevant, core), function([dir,name]) {
let fullname = dir + name;
if(fs.statSync(fullname).isDirectory() && fs.existsSync(path.join(fullname, "package.json"))) {
console.log("*** Executing npm install in "+fullname);
exec('npm install', {
cwd: fullname,
stdio: 'inherit'
});
console.log("*** Executing npm run build-prod in "+fullname);
exec('npm run build-prod', {
cwd: fullname,
stdio: 'inherit'
});
}
});
var testable = args.check ? relevant : [];
_.each(testable, function([dir,name]) {
let fullname = dir + name;
if(fs.statSync(fullname).isDirectory() && fs.existsSync(path.join(fullname, "package.json"))) {
console.log("*** Executing npm run selenium for "+fullname);
exec('npm run selenium -- --count 1 --fork false --framework ' + name, {
cwd: "webdriver-ts",
stdio: 'inherit'
});
}
});
function isDifferent([dir,name]) {
try { exec('git diff --quiet ' + referenceBranch + ' -- ' + dir + name); }
catch(e) { return true; }
return false;
};