Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92adf34

Browse files
author
John Haley
committed
Configure node-gyp for compiling with nwjs/electron
1 parent 3fe3b98 commit 92adf34

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

lifecycleScripts/install.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,20 +67,52 @@ function prepareAndBuild() {
6767
function build() {
6868
console.info("[nodegit] Everything is ready to go, attempting compilation");
6969

70+
var electronVersion = process.env.ELECTRON_VERSION;
71+
var nwjsVersion = process.env.NWJS_VERSION;
7072
var opts = {
7173
cwd: ".",
7274
maxBuffer: Number.MAX_VALUE,
7375
env: process.env
7476
};
7577

78+
var builder = "node-gyp";
7679
var debug = (process.env.BUILD_DEBUG ? " --debug" : "");
80+
var target;
81+
var distUrl;
82+
83+
process.argv.forEach(function(arg) {
84+
if (~arg.indexOf("electronVersion")) {
85+
electronVersion = arg.split("=")[1].trim();
86+
}
87+
else if (~arg.indexOf("nsjwVersion")) {
88+
nwjsVersion = arg.split("=")[1].trim();
89+
}
90+
});
91+
92+
if (electronVersion) {
93+
target = "--target=" + electronVersion;
94+
distUrl = "--dist-url=https://gh-contractor-zcbenz.s3." +
95+
"amazonaws.com/atom-shell/dist";
96+
}
97+
else if (nwjsVersion) {
98+
builder = "nw-gyp";
99+
target = "--target=" + nwjsVersion;
100+
}
77101

78102
var home = process.platform == "win32" ?
79103
process.env.USERPROFILE : process.env.HOME;
80104

81105
opts.env.HOME = path.join(home, ".nodegit-gyp");
82106

83-
var cmd = [pathForTool("node-gyp"), "rebuild", debug].join(" ").trim();
107+
var cmd = [
108+
pathForTool(builder),
109+
"rebuild",
110+
debug,
111+
target,
112+
distUrl
113+
]
114+
.join(" ")
115+
.trim();
84116

85117
return exec(cmd, opts)
86118
.then(function() {

0 commit comments

Comments
 (0)