forked from RSATom/WebChimera.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rebuild.js
52 lines (42 loc) · 1.25 KB
/
rebuild.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
function build() {
var cmakeJS = require("cmake-js");
var defaultRuntime = "electron";
var defaultRuntimeVersion = "20.0.2";
var defaultWinArch = "x64";
var options = {
runtime: process.env.npm_config_wcjs_runtime || undefined,
runtimeVersion: process.env.npm_config_wcjs_runtime_version || undefined,
arch: process.env.npm_config_wcjs_arch || undefined
};
var buildSystem = new cmakeJS.BuildSystem(options);
if (buildSystem.options.runtime == undefined) {
buildSystem.options.runtime = defaultRuntime;
}
if (buildSystem.options.runtimeVersion == undefined) {
buildSystem.options.runtimeVersion = defaultRuntimeVersion;
}
if (buildSystem.options.arch == undefined && process.platform == "win32") {
buildSystem.options.arch = defaultWinArch;
}
buildSystem.rebuild().catch( function() { process.exit(1); } );
}
var times = 0;
function begin() {
try {
build();
}
catch(e) {
if (e.code == "MODULE_NOT_FOUND") {
if (times++ == 5) {
process.exit(1);
}
else {
setTimeout(begin, 2000);
}
}
else {
process.exit(1);
}
}
};
begin();