Skip to content

Commit e7ff929

Browse files
author
John Haley
committed
Fix build on linux
1 parent 805edba commit e7ff929

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

lifecycleScripts/install.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
var path = require("path");
22

33
var buildFlags = require("../utils/buildFlags");
4-
var exec = require("../utils/execPromise");
4+
var spawn = require("child_process").spawn;
55

66
module.exports = function install() {
77
console.log("[nodegit] Running install script");
88

9-
var nodePreGypCmd = path.join(
9+
var nodePreGyp = path.join(
1010
__dirname,
1111
"..",
1212
"node_modules",
@@ -15,27 +15,45 @@ module.exports = function install() {
1515
);
1616

1717
if (process.platform === "win32") {
18-
nodePreGypCmd += ".cmd";
18+
nodePreGyp += ".cmd";
1919
}
2020

21-
var cmd = [nodePreGypCmd, "install"];
21+
var args = ["install"];
2222

2323
if (buildFlags.mustBuild) {
2424
console.info(
2525
"[nodegit] Pre-built download disabled, building from source."
2626
);
27-
cmd.push("--build-from-source");
27+
args.push("--build-from-source");
2828

2929
if (buildFlags.debugBuild) {
3030
console.info("[nodegit] Building debug version.");
31-
cmd.push("--debug");
31+
args.push("--debug");
3232
}
3333
}
3434
else {
35-
cmd.push("--fallback-to-build");
35+
args.push("--fallback-to-build");
3636
}
3737

38-
return exec(cmd.join(" "))
38+
return new Promise(function(resolve, reject) {
39+
var spawnedNodePreGyp = spawn(nodePreGyp, args);
40+
41+
spawnedNodePreGyp.stdout.on("data", function(data) {
42+
console.info(data.toString());
43+
});
44+
45+
spawnedNodePreGyp.stderr.on("data", function(data) {
46+
console.error(data.toString());
47+
});
48+
49+
spawnedNodePreGyp.on("close", function(code) {
50+
if (!code) {
51+
resolve();
52+
} else {
53+
reject(code);
54+
}
55+
});
56+
})
3957
.then(function() {
4058
console.info("[nodegit] Completed installation successfully.");
4159
});
@@ -46,7 +64,7 @@ if (require.main === module) {
4664
module.exports()
4765
.catch(function(e) {
4866
console.error("[nodegit] ERROR - Could not finish install");
49-
console.error(e);
50-
process.exit(1);
67+
console.error("[nodegit] ERROR - finished with error code: " + e);
68+
process.exit(e);
5169
});
5270
}

0 commit comments

Comments
 (0)