-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.js
66 lines (54 loc) · 1.94 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
const copy = require('recursive-copy');
const path = require('path');
const fs = require('fs');
class Build {
constructor () {
this.paths = [
["node_modules", path.join("dist", "node_modules")],
["steps", path.join("dist", "steps")],
["features", path.join("dist", "features")],
["cucumber.conf.js", path.join("dist", "cucumber.conf.js")],
["nightwatch.conf.js", path.join("dist","nightwatch.conf.js")],
["features_disabled", path.join("dist", "features_disabled")],
["run_chrome.bat", path.join("dist", "run_chrome.bat")],
["run_firefox.bat", path.join("dist", "run_firefox.bat")]
];
this.runtimeConfigContent =
`module.exports = {
email: "[email protected]",
password: "pa$$w0rd"
}`;
}
_copy(resourcePath, resourceDestination) {
let result = true;
copy(resourcePath, resourceDestination)
.on(copy.events.ERROR, (error, copyOperation) => {
console.error('Unable to copy ' + copyOperation.dest);
})
.then((results) => {
console.info(results.length + ' file(s) copied');
})
.catch((error) => {
console.error('Copy failed: ' + error);
result = false;
});
return result;
}
run() {
this.paths.every(resource => {
const isSuccessful = this._copy(resource[0], resource[1]);
if (!isSuccessful) {
console.error("Error copying files.");
}
return isSuccessful;
});
fs.writeFile(path.join("dist", "runtime.config"), this.runtimeConfigContent, err => {
if (err) {
console.error("couldn't generate runtime.config file.");
} else {
console.info("runtime.config generated.");
}
});
}
}
new Build().run();