forked from libgit2/node-gitteh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
62 lines (57 loc) · 1.52 KB
/
install.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
53
54
55
56
57
58
59
60
61
62
var async = require("async"),
child_process = require("child_process"),
spawn = child_process.spawn,
path = require("path");
function passthru() {
var args = Array.prototype.slice.call(arguments);
var cb = args.splice(-1)[0];
var cmd = args.splice(0, 1)[0];
var opts = {};
if(typeof(args.slice(-1)[0]) === "object") {
opts = args.splice(-1)[0];
}
var child = spawn(cmd, args, opts);
child.stdout.pipe(process.stdout);
child.stderr.pipe(process.stderr);
child.on("exit", cb);
}
function shpassthru() {
var cmd =
passthru.apply(null, ["/bin/sh", "-c"].concat(Array.prototype.slice.call(arguments)));
}
function envpassthru() {
passthru.apply(null, ["/usr/bin/env"].concat(Array.prototype.slice.call(arguments)));
}
var buildDir = path.join(__dirname, "deps/libgit2/build");
async.series([
function(cb) {
console.log("[gitteh] Downloading libgit2 dependency.");
envpassthru("git", "submodule", "init", cb);
},
function(cb) {
envpassthru("git", "submodule", "update", cb);
},
function(cb) {
console.log("[gitteh] Building libgit2 dependency.");
envpassthru("mkdir", "-p", buildDir, cb);
},
function(cb) {
envpassthru("cmake", "-DTHREADSAFE=1", "-DBUILD_CLAR=0", "..", {
cwd: buildDir
}, cb);
},
function(cb) {
envpassthru("cmake", "--build", ".", {
cwd: buildDir
}, cb);
},
function(cb) {
console.log("[gitteh] Building native module.");
shpassthru("node-gyp configure --debug", cb);
},
function(cb) {
shpassthru("node-gyp build", cb);
}
], function(err) {
if(err) process.exit(err);
});