Skip to content

Commit 805edba

Browse files
author
John Haley
committed
Fix build on windows
1 parent 9543011 commit 805edba

File tree

4 files changed

+66
-55
lines changed

4 files changed

+66
-55
lines changed

lifecycleScripts/configureLibssh2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ if (require.main === module) {
4242
console.log("nothing to do");
4343
}
4444
else {
45-
module.exports();
45+
module.exports().done();
4646
}
4747
}

lifecycleScripts/install.js

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,52 @@
1-
var nodePreGypConstructor = require("node-pre-gyp");
2-
var nodePreGyp = new nodePreGypConstructor.Run();
1+
var path = require("path");
2+
33
var buildFlags = require("../utils/buildFlags");
4+
var exec = require("../utils/execPromise");
45

56
module.exports = function install() {
67
console.log("[nodegit] Running install script");
78

8-
// we need to add 2 blank entires to help the parser later.
9-
var argv = ["", "", "install"];
9+
var nodePreGypCmd = path.join(
10+
__dirname,
11+
"..",
12+
"node_modules",
13+
".bin",
14+
"node-pre-gyp"
15+
);
16+
17+
if (process.platform === "win32") {
18+
nodePreGypCmd += ".cmd";
19+
}
20+
21+
var cmd = [nodePreGypCmd, "install"];
1022

1123
if (buildFlags.mustBuild) {
12-
argv.push("--build-from-source");
24+
console.info(
25+
"[nodegit] Pre-built download disabled, building from source."
26+
);
27+
cmd.push("--build-from-source");
1328

1429
if (buildFlags.debugBuild) {
15-
argv.push("--debug");
30+
console.info("[nodegit] Building debug version.");
31+
cmd.push("--debug");
1632
}
1733
}
1834
else {
19-
argv.push("--fallback-to-build");
35+
cmd.push("--fallback-to-build");
2036
}
2137

22-
nodePreGyp.parseArgv(argv);
23-
24-
function run() {
25-
var command = nodePreGyp.todo.shift();
26-
if (!command) {
27-
return;
28-
}
29-
30-
nodePreGyp.commands[command.name](command.args, function (err) {
31-
if (err) {
32-
console.error(command.name + " error");
33-
console.error("stack", err.stack);
34-
console.error("not ok");
35-
console.log(err.message);
36-
return process.exit(1);
37-
}
38-
var args_array = [].slice.call(arguments, 1);
39-
if (args_array.length) {
40-
console.log.apply(console, args_array);
41-
}
42-
// now run the next command in the queue
43-
process.nextTick(run);
38+
return exec(cmd.join(" "))
39+
.then(function() {
40+
console.info("[nodegit] Completed installation successfully.");
4441
});
45-
}
46-
47-
run();
4842
};
4943

5044
// Called on the command line
5145
if (require.main === module) {
52-
module.exports();
46+
module.exports()
47+
.catch(function(e) {
48+
console.error("[nodegit] ERROR - Could not finish install");
49+
console.error(e);
50+
process.exit(1);
51+
});
5352
}

lifecycleScripts/postinstall.js

Lines changed: 32 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
#!/usr/bin/env node
2-
31
var fse = require("fs-extra");
42
var path = require("path");
5-
var child_process = require("child_process");
3+
4+
var exec = require("../utils/execPromise");
65
var buildFlags = require("../utils/buildFlags");
76

87
var rootPath = path.join(__dirname, "..");
@@ -16,25 +15,37 @@ function printStandardLibError() {
1615
console.log("");
1716
console.log("$ sudo add-apt-repository ppa:ubuntu-toolchain-r/test");
1817
console.log("$ sudo apt-get update");
18+
console.log("$ sudo apt-get install libstdc++-4.9-dev");
1919
}
2020

21-
console.log("$ sudo apt-get install libstdc++-4.9-dev");
22-
child_process.exec("node dist/nodegit.js", function(error, stdout, stderr) {
23-
if (stderr) {
24-
if (process.pladtform !== "linux" && ~stderr.indexOf("libstdc++")) {
25-
printStandardLibError();
26-
}
21+
module.exports = function install() {
22+
return exec("node dist/nodegit.js")
23+
.then(function() {
24+
// Is we're using NodeGit from a package manager then let's clean up after
25+
// ourselves when we install successfully.
26+
if (!buildFlags.mustBuild) {
27+
fse.removeSync(path.join(rootPath, "vendor"));
28+
fse.removeSync(path.join(rootPath, "src"));
29+
fse.removeSync(path.join(rootPath, "include"));
30+
fse.removeSync(path.join(rootPath, "build/Release/*.a"));
31+
fse.removeSync(path.join(rootPath, "build/Release/obj.target"));
32+
}
33+
});
34+
};
2735

28-
return;
29-
}
36+
// Called on the command line
37+
if (require.main === module) {
38+
module.exports()
39+
.catch(function(e) {
40+
console.error("[nodegit] ERROR - Could not finish postinstall");
3041

31-
// Is we're using NodeGit from a package manager then let's clean up after
32-
// ourselves when we install successfully.
33-
if (!buildFlags.mustBuild) {
34-
fse.removeSync(path.join(rootPath, "vendor"));
35-
fse.removeSync(path.join(rootPath, "src"));
36-
fse.removeSync(path.join(rootPath, "include"));
37-
fse.removeSync(path.join(rootPath, "build/Release/*.a"));
38-
fse.removeSync(path.join(rootPath, "build/Release/obj.target"));
39-
}
40-
});
42+
if (process.pladtform !== "linux" && ~e.indexOf("libstdc++")) {
43+
printStandardLibError();
44+
}
45+
else {
46+
console.error(e);
47+
}
48+
49+
process.exit(1);
50+
});
51+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"fs-extra": "~0.26.2",
4242
"lodash": "^4.13.1",
4343
"nan": "^2.2.0",
44+
"node-gyp": "^3.3.1",
4445
"node-pre-gyp": "~0.6.15",
4546
"promisify-node": "~0.3.0"
4647
},

0 commit comments

Comments
 (0)