@@ -46,6 +46,7 @@ var paths = envOverride({
4646 pkg : local ( "package" ) ,
4747 libgit2 : local ( "vendor/libgit2/" ) ,
4848 libssh2 : local ( "vendor/libssh2/" ) ,
49+ http_parser : local ( "vendor/http_parser/" ) ,
4950 sys : {
5051 include : local ( "include/sys/" ) ,
5152 src : local ( "src/sys/" ) ,
@@ -121,7 +122,7 @@ var dependencies = Q.allSettled([
121122 } ) ;
122123} )
123124
124- // Grab libssh2 if needed
125+ // Grab libssh2 if needed.
125126. then ( function ( ) {
126127 console . info ( "[nodegit] Detecting vendor/libssh2." ) ;
127128
@@ -156,11 +157,55 @@ var dependencies = Q.allSettled([
156157 } ) . then ( function ( ) {
157158 // Only run the configuration script in a BSD-like environment.
158159 if ( process . platform !== "win32" ) {
159- return Q . nfcall ( exec , "cd " + paths . libssh2 + " ; " + paths . libssh2 + "configure" ) ;
160+ return Q . nfcall ( exec , "cd " + paths . libssh2 + " ; " + paths . libssh2 +
161+ "configure" ) ;
160162 }
161163 } ) ;
162164} )
163165
166+ // Grab http-parser if needed.
167+ . then ( function ( ) {
168+ console . info ( "[nodegit] Detecting vendor/http_parser." ) ;
169+
170+ return Q . ninvoke ( fs , "stat" , paths . http_parser ) . then ( function ( ) {
171+ return Q . ninvoke ( fs , "stat" , paths . http_parser + pkg . http_parser . version ) ;
172+ } ) . fail ( function ( ) {
173+ console . info ( "[nodegit] Removing outdated vendor/http_parser." ) ;
174+
175+ // This directory is outdated, remove.
176+ throw Q . ninvoke ( rimraf , null , paths . http_parser ) ;
177+ } ) ;
178+ } )
179+
180+ // If the directory already exists, no need to refetch.
181+ . fail ( function ( ) {
182+ // Otherwise fetch the http_parser source.
183+ console . info ( "[nodegit] Fetching vendor/http_parser." ) ;
184+
185+ var url = pkg . http_parser . url ;
186+
187+ var extract = tar . Extract ( {
188+ path : paths . http_parser ,
189+ strip : true
190+ } ) ;
191+
192+ // First extract from Zlib and then extract from Tar.
193+ var expand = request . get ( url ) . pipe ( zlib . createUnzip ( ) ) . pipe ( extract ) ;
194+
195+ return Q . ninvoke ( expand , "on" , "end" ) . then ( function ( ) {
196+ // Write out a sha file for testing in the future.
197+ return Q . ninvoke ( fs , "writeFile" , paths . http_parser +
198+ pkg . http_parser . version , "" ) ;
199+ } ) . then ( function ( ) {
200+ // Only run the configuration script in a BSD-like environment.
201+ if ( process . platform !== "win32" ) {
202+ return Q . nfcall ( exec , "cd " + paths . http_parser + " ; " +
203+ paths . http_parser + "configure" ) ;
204+ }
205+ } ) ;
206+ } )
207+
208+
164209// Build the native module using node-gyp.
165210. then ( function ( ) {
166211 console . info ( "[nodegit] Building native node module." ) ;
0 commit comments