Skip to content

Commit cef1521

Browse files
committed
Improve the installation flow.
1 parent ca6118f commit cef1521

File tree

1 file changed

+20
-24
lines changed

1 file changed

+20
-24
lines changed

install.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,6 @@ var dependencies = Q.allSettled([
8888
});
8989
})
9090

91-
// Display a warning message about missing dependencies.
92-
.fail(function(message) {
93-
console.info('[nodegit] Failed to build nodegit.');
94-
console.info(message);
95-
96-
throw new Error(message);
97-
})
98-
9991
// Successfully found all dependencies. First step is to clean the vendor
10092
// directory.
10193
.then(function() {
@@ -108,7 +100,7 @@ var dependencies = Q.allSettled([
108100
.then(function() {
109101
console.info('[nodegit] Fetching vendor/libgit2.');
110102

111-
var url = 'https://github.com/libgit2/libgit2/tarball/'+ pkg.libgit2;
103+
var url = 'https://github.com/libgit2/libgit2/tarball/' + pkg.libgit2;
112104

113105
var extract = tar.Extract({
114106
path: paths.libgit2,
@@ -128,25 +120,29 @@ var dependencies = Q.allSettled([
128120
return Q.ninvoke(fs, 'mkdir', paths.build);
129121
})
130122

131-
// Configure libgit2.
123+
// Configure libgit2 using cmake.
132124
.then(function() {
133125
console.info('[nodegit] Configuring libgit2.');
134126

135-
var flags = '-DTHREADSAFE=1 -DBUILD_CLAR=0';
127+
// Minimum flags necessary to configure in sane environments.
128+
var flags = ['-DTHREADSAFE=ON', '-DBUILD_CLAR=OFF'];
136129

137130
// Windows flags.
138-
if (process.platform.indexOf("win") > -1) {
139-
flags = '-DSTDCALL=OFF -DBUILD_CLAR=OFF -DTHREADSAFE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS=-fPIC -DCMAKE_BUILD_TYPE=RelWithDebInfo';
131+
if (process.platform.indexOf('win') > -1) {
132+
flags.push.apply(flags, [
133+
'-DSTDCALL=OFF',
134+
'-DBUILD_SHARED_LIBS=OFF',
135+
'-DCMAKE_C_FLAGS=-fPIC',
136+
'-DCMAKE_BUILD_TYPE=RelWithDebInfo'
137+
]);
140138
}
141139

142-
return Q.nfcall(exec, 'cmake .. ' + flags, {
140+
return Q.nfcall(exec, 'cmake .. ' + flags.join(' '), {
143141
cwd: paths.build
144142
});
145-
}).fail(function(err) {
146-
console.error(err);
147143
})
148144

149-
// Build libgit2.
145+
// Build libgit2 using cmake.
150146
.then(function() {
151147
console.info('[nodegit] Building libgit2.');
152148

@@ -155,7 +151,7 @@ var dependencies = Q.allSettled([
155151
});
156152
})
157153

158-
// Configure the Node native module.
154+
// Configure the native module using node-gyp.
159155
.then(function() {
160156
console.info('[nodegit] Configuring native node module.');
161157

@@ -166,6 +162,7 @@ var dependencies = Q.allSettled([
166162
});
167163
})
168164

165+
// Build the native module using node-gyp.
169166
.then(function() {
170167
console.info('[nodegit] Building native node module.');
171168

@@ -176,15 +173,14 @@ var dependencies = Q.allSettled([
176173
});
177174
})
178175

176+
// Display a success message.
177+
.then(function() {
178+
console.info('[nodegit] Completed installation successfully.');
179+
})
180+
179181
// Display a warning message about failing to build native node module.
180182
.fail(function(message) {
181183
console.info('[nodegit] Failed to build nodegit.');
182184
console.info(message.message);
183185
console.info(message.stack);
184-
185-
throw new Error(message);
186-
})
187-
188-
.then(function() {
189-
console.info('[nodegit] Completed installation successfully.');
190186
});

0 commit comments

Comments
 (0)