Skip to content

Commit 79a2ad2

Browse files
committed
Better installation flow for developing.
1 parent 37be1ee commit 79a2ad2

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

install.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ var Q = require('q');
1010
var request = require('request');
1111
var tar = require('tar');
1212
var which = require('which');
13-
var rimraf = require('rimraf');
1413

1514
// This will take in an object and find any matching keys in the environment
1615
// to use as overrides.
@@ -89,19 +88,20 @@ var dependencies = Q.allSettled([
8988
});
9089
})
9190

92-
// Successfully found all dependencies. First step is to clean the vendor
91+
// Successfully found all dependencies. First step is to detect the vendor
9392
// directory.
9493
.then(function() {
95-
console.info('[nodegit] Removing vendor/libgit2.');
94+
console.info('[nodegit] Detecting vendor/libgit2.');
9695

97-
return Q.ninvoke(rimraf, null, paths.libgit2);
96+
return Q.ninvoke(fs, 'stat', paths.libgit2);
9897
})
9998

100-
// Now fetch the libgit2 source from GitHub.
101-
.then(function() {
99+
// If the directory already exists, no need to refetch.
100+
.fail(function() {
101+
// Otherwise fetch the libgit2 source from GitHub.
102102
console.info('[nodegit] Fetching vendor/libgit2.');
103103

104-
var url = 'https://github.com/libgit2/libgit2/tarball/' + pkg.libgit2;
104+
var url = 'https://github.com/libgit2/libgit2/tarball/' + pkg.libgit2.sha;
105105

106106
var extract = tar.Extract({
107107
path: paths.libgit2,
@@ -111,10 +111,10 @@ var dependencies = Q.allSettled([
111111
// First extract from Zlib and then extract from Tar.
112112
var expand = request.get(url).pipe(zlib.createUnzip()).pipe(extract);
113113

114-
return Q.ninvoke(expand, 'on', 'end');
114+
return Q.ninvoke(expand, 'on', 'end')
115115
})
116116

117-
// Fetch completed successfully.
117+
// Fetch completed, make the build directory.
118118
.then(function() {
119119
console.info('[nodegit] Creating vendor/libgit2/build.');
120120

@@ -157,6 +157,11 @@ var dependencies = Q.allSettled([
157157
});
158158
})
159159

160+
.fail(function() {
161+
console.info('[nodegit] libgit2 already built');
162+
return true;
163+
})
164+
160165
// Configure the native module using node-gyp.
161166
.then(function() {
162167
console.info('[nodegit] Configuring native node module.');

0 commit comments

Comments
 (0)