@@ -10,6 +10,9 @@ 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 . env . BUILD_ONLY ;
15+
1316// This will take in an object and find any matching keys in the environment
1417// to use as overrides.
1518//
@@ -63,13 +66,34 @@ if (NODE_VERSION === 0.1) {
6366 pkg . http_parser = pkg . http_parser [ "0.10" ] ;
6467}
6568
66- // Ensure all dependencies are available.
67- var dependencies = Q . allSettled ( [
68- // This will prioritize `python2` over `python`, because we always want to
69- // work with Python 2.* if it"s available.
70- Q . nfcall ( which , "python2" ) ,
71- Q . nfcall ( which , "python" )
72- ] )
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+ } )
7397
7498// Determine if all the dependency requirements are met.
7599. then ( function ( results ) {
@@ -218,25 +242,6 @@ var dependencies = Q.allSettled([
218242 } ) ;
219243} )
220244
221- // Attempt to fallback on a prebuilt binary.
222- . fail ( function ( message ) {
223- console . info ( "[nodegit] Failed to build nodegit." ) ;
224- console . info ( "[nodegit] Attempting to fallback on a prebuilt binary." ) ;
225-
226- console . log ( message . stack ) ;
227-
228- function fetchPrebuilt ( ) {
229- console . info ( "[nodegit] Fetching binary from S3." ) ;
230-
231- // Using the node-pre-gyp module, attempt to fetch a compatible build.
232- return Q . nfcall ( exec , "node-pre-gyp install" ) ;
233- }
234-
235- // Attempt to fetch prebuilt binary.
236- return Q . ninvoke ( fs , "mkdir" , paths . release )
237- . then ( fetchPrebuilt , fetchPrebuilt ) ;
238- } )
239-
240245// Display a warning message about failing to build native node module.
241246. fail ( function ( message ) {
242247 console . info ( "[nodegit] Failed to build and install nodegit." ) ;
0 commit comments