-
Notifications
You must be signed in to change notification settings - Fork 700
Expand file tree
/
Copy pathinstall.js
More file actions
executable file
·75 lines (62 loc) · 1.97 KB
/
install.js
File metadata and controls
executable file
·75 lines (62 loc) · 1.97 KB
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
67
68
69
70
71
72
73
74
75
var buildFlags = require("../utils/buildFlags");
var spawn = require("child_process").spawn;
var path = require("path");
const nodePreGypModulePath = require.resolve("@mapbox/node-pre-gyp");
module.exports = function install() {
console.log("[nodegit] Running install script");
var nodePreGyp = "node-pre-gyp";
if (process.platform === "win32") {
nodePreGyp += ".cmd";
}
var args = ["install"];
if (buildFlags.mustBuild) {
console.info(
"[nodegit] Pre-built download disabled, building from source."
);
args.push("--build-from-source");
if (buildFlags.debugBuild) {
console.info("[nodegit] Building debug version.");
args.push("--debug");
}
}
else {
args.push("--fallback-to-build");
}
return new Promise(function(resolve, reject) {
const gypPath = path.join(__dirname, "..", "node_modules", "node-gyp", "bin", "node-gyp.js");
const nodePreGypPath = path.resolve(path.dirname(nodePreGypModulePath), path.join("..", "bin", nodePreGyp));
console.log("node-pre-gyp path", nodePreGypPath);
var spawnedNodePreGyp = spawn(nodePreGypPath, args, {
env: {
...process.env,
npm_config_node_gyp: gypPath
},
shell: process.platform === "win32"
});
spawnedNodePreGyp.stdout.on("data", function(data) {
console.info(data.toString().trim());
});
spawnedNodePreGyp.stderr.on("data", function(data) {
console.error(data.toString().trim());
});
spawnedNodePreGyp.on("close", function(code) {
if (!code) {
resolve();
} else {
reject(code);
}
});
})
.then(function() {
console.info("[nodegit] Completed installation successfully.");
});
};
// Called on the command line
if (require.main === module) {
module.exports()
.catch(function(e) {
console.error("[nodegit] ERROR - Could not finish install");
console.error("[nodegit] ERROR - finished with error code: " + e);
process.exit(e);
});
}