@@ -10,13 +10,8 @@ var which = require("which");
1010var rimraf = require ( "rimraf" ) ;
1111var NODE_VERSION = Number ( process . version . match ( / ^ v ( \d + \. \d + ) / ) [ 1 ] ) ;
1212
13- // If the build only flag is set
14- var buildOnly = process . argv . indexOf ( "--build-only" ) > - 1 ;
15-
16- if ( buildOnly ) {
17- console . log ( "buildOnly" ) ;
18- return ;
19- }
13+ // If the build only flag is set.
14+ var buildOnly = process . env . BUILD_ONLY ;
2015
2116// This will take in an object and find any matching keys in the environment
2217// to use as overrides.
@@ -71,13 +66,34 @@ if (NODE_VERSION === 0.1) {
7166 pkg . http_parser = pkg . http_parser [ "0.10" ] ;
7267}
7368
74- // Ensure all dependencies are available.
75- var dependencies = Q . allSettled ( [
76- // This will prioritize `python2` over `python`, because we always want to
77- // work with Python 2.* if it"s available.
78- Q . nfcall ( which , "python2" ) ,
79- Q . nfcall ( which , "python" )
80- ] )
69+ // Attempt to fallback on a prebuilt binary.
70+ function fetchPrebuilt ( ) {
71+ if ( ! buildOnly ) {
72+ console . info ( "[nodegit] Fetching binary from S3." ) ;
73+
74+ // Using the node-pre-gyp module, attempt to fetch a compatible build.
75+ return Q . nfcall ( exec , "node-pre-gyp install" ) ;
76+ }
77+
78+ throw new Error ( "Build only" ) ;
79+ }
80+
81+ // Attempt to fetch prebuilt binary.
82+ Q . ninvoke ( fs , "mkdir" , paths . release ) . then ( fetchPrebuilt , fetchPrebuilt )
83+
84+ . fail ( function ( ) {
85+ if ( ! buildOnly ) {
86+ console . info ( "[nodegit] Failed to install prebuilt, attempting compile." ) ;
87+ }
88+
89+ // Ensure all dependencies are available.
90+ return Q . allSettled ( [
91+ // This will prioritize `python2` over `python`, because we always want to
92+ // work with Python 2.* if it"s available.
93+ Q . nfcall ( which , "python2" ) ,
94+ Q . nfcall ( which , "python" )
95+ ] )
96+ } )
8197
8298// Determine if all the dependency requirements are met.
8399. then ( function ( results ) {
@@ -226,25 +242,6 @@ var dependencies = Q.allSettled([
226242 } ) ;
227243} )
228244
229- // Attempt to fallback on a prebuilt binary.
230- . fail ( function ( message ) {
231- console . info ( "[nodegit] Failed to build nodegit." ) ;
232- console . info ( "[nodegit] Attempting to fallback on a prebuilt binary." ) ;
233-
234- console . log ( message . stack ) ;
235-
236- function fetchPrebuilt ( ) {
237- console . info ( "[nodegit] Fetching binary from S3." ) ;
238-
239- // Using the node-pre-gyp module, attempt to fetch a compatible build.
240- return Q . nfcall ( exec , "node-pre-gyp install" ) ;
241- }
242-
243- // Attempt to fetch prebuilt binary.
244- return Q . ninvoke ( fs , "mkdir" , paths . release )
245- . then ( fetchPrebuilt , fetchPrebuilt ) ;
246- } )
247-
248245// Display a warning message about failing to build native node module.
249246. fail ( function ( message ) {
250247 console . info ( "[nodegit] Failed to build and install nodegit." ) ;
0 commit comments