@@ -47,6 +47,7 @@ var paths = envOverride({
4747 pkg : __dirname + '/package' ,
4848 libgit2 : __dirname + '/vendor/libgit2/' ,
4949 build : __dirname + '/vendor/libgit2/build/' ,
50+ release : __dirname + '/build/Release'
5051} ) ;
5152
5253// Load the package.json.
@@ -67,20 +68,12 @@ var dependencies = Q.allSettled([
6768. then ( function ( results ) {
6869 console . info ( '[nodegit] Determining dependencies.' ) ;
6970
71+ //throw new Error("can't build");
72+
7073 // Assign to reusable variables.
7174 python = results [ 0 ] . value || results [ 1 ] . value ;
7275 cmake = results [ 2 ] . value ;
7376
74- // Missing Python.
75- if ( ! python ) {
76- throw new Error ( 'Python is required to build libgit2.' ) ;
77- }
78-
79- // Missing CMake.
80- if ( ! cmake ) {
81- //throw new Error('CMake is required to build libgit2.');
82- }
83-
8477 // Now lets check the Python version to ensure it's < 3.
8578 return Q . nfcall ( exec , python + ' --version' ) . then ( function ( version ) {
8679 if ( version [ 1 ] . indexOf ( 'Python 3' ) === 0 ) {
@@ -190,4 +183,35 @@ var dependencies = Q.allSettled([
190183 console . info ( '[nodegit] Failed to build nodegit.' ) ;
191184 console . info ( message . message ) ;
192185 console . info ( message . stack ) ;
193- } ) ;
186+
187+ // Attempt the prebuilt fallback.
188+ console . info ( '[nodegit] Removing vendor/libgit2.' ) ;
189+
190+ return Q . ninvoke ( rimraf , null , paths . release ) . then ( function ( ) {
191+ console . info ( '[nodegit] Creating build/Release.' ) ;
192+
193+ // Attempt to fetch prebuilt binary.
194+ return Q . ninvoke ( fs , 'mkdir' , paths . release ) . then ( function ( ) {
195+ console . info ( '[nodegit] Attempting to fetch a prebuilt binary.' ) ;
196+
197+ var version = [
198+ process . platform , process . arch , require ( "./package.json" ) . version
199+ ] . join ( '_' ) ;
200+
201+ var url = 'https://s3.amazonaws.com/nodegit/' + version ;
202+
203+ var extract = tar . Extract ( {
204+ path : paths . release ,
205+ strip : true
206+ } ) ;
207+
208+ var expand = request . get ( url ) . pipe ( zlib . createUnzip ( ) ) . pipe ( extract ) ;
209+
210+ return Q . ninvoke ( expand , 'on' , 'end' ) ;
211+ } )
212+
213+ . then ( function ( ) {
214+ console . info ( '[nodegit] Completed installation successfully.' ) ;
215+ } ) ;
216+ } ) ;
217+ } )
0 commit comments