forked from PubMatic/OpenWrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildfile.js
58 lines (42 loc) · 1.38 KB
/
buildfile.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
console.log("running from shell script");
var shell = require('shelljs');
var argv = require('yargs').argv;
shell.exec("gulp clean");
var prebidRepoPath = argv.prebidpath || "../Prebid.js/";
console.log("ARGV ==>", argv);
if(shell.cd(prebidRepoPath).code !== 0) {
shell.echo("Couldnt change the dir to Prebid repo");
shell.exit(1);
}
var buildTaskName = "bundle";
var webpackTaskName = "pack";
if ( argv.mode && argv.mode == "test-build") {
console.log("Executing test-build");
buildTaskName = "dev" + buildTaskName;
webpackTaskName = "dev" + webpackTaskName;
} else if ( argv.mode && argv.mode == "build" ) {
console.log("Executing build");
webpackTaskName = "web" + webpackTaskName;
} else {
console.log("No mode supplied, Too few arguments");
shell.exit(1);
}
if(shell.exec("gulp " + webpackTaskName + " --mode=" + argv.mode).code !== 0) {
shell.echo('Error: buidlinng of project failed');
shell.exit(1);
}
shell.cd("../OpenWrap/");
if (argv.mode == "test-build") {
if(shell.exec("gulp testall" + " --mode=" + argv.mode).code !== 0) {
shell.echo('Error: test cases failed');
shell.exit(1);
}
}
if(shell.exec("gulp " + webpackTaskName + " --mode=" + argv.mode).code !== 0) {
shell.echo('Error: webpack task failed');
shell.exit(1);
}
if(shell.exec("gulp " + buildTaskName + " --mode=" + argv.mode).code !== 0) {
shell.echo('Error: build task failed');
shell.exit(1);
}