@@ -26,7 +26,8 @@ return installPrebuilt();
2626
2727function installPrebuilt ( ) {
2828 console . info ( "[nodegit] Fetching binary from S3." ) ;
29- return exec ( "node-pre-gyp install --fallback-to-build=false" )
29+ var npg = pathForTool ( "node-pre-gyp" ) ;
30+ return exec ( npg + " install --fallback-to-build=false" )
3031 . then (
3132 function ( ) {
3233 console . info ( "[nodegit] Completed installation successfully." ) ;
@@ -41,6 +42,13 @@ function installPrebuilt() {
4142}
4243
4344
45+ function pathForTool ( name ) {
46+ var toolPath = path . resolve ( "." , "node_modules" , ".bin" , name ) ;
47+ toolPath = toolPath . replace ( / \s / g, "\\$&" ) ;
48+ return toolPath ;
49+ }
50+
51+
4452function prepareAndBuild ( ) {
4553 console . info ( "[nodegit] Regenerating and configuring code" ) ;
4654 return prepareForBuild ( )
@@ -59,15 +67,13 @@ function build() {
5967 } ;
6068
6169 var debug = ( process . env . BUILD_DEBUG ? " --debug" : "" ) ;
62- var builder = "node-gyp" ;
6370
6471 var home = process . platform == "win32" ?
6572 process . env . USERPROFILE : process . env . HOME ;
6673
6774 opts . env . HOME = path . join ( home , ".nodegit-gyp" ) ;
6875
69- builder = path . resolve ( "." , "node_modules" , ".bin" , builder ) ;
70- builder = builder . replace ( / \s / g, "\\$&" ) ;
76+ var builder = pathForTool ( "node-gyp" ) ;
7177 var cmd = [ builder , "rebuild" , debug ] . join ( " " ) . trim ( ) ;
7278
7379 return exec ( cmd , opts )
0 commit comments