@@ -6,21 +6,28 @@ var fs = require("fs");
66var local = path . join . bind ( path , __dirname ) ;
77
88var checkPrepared = require ( local ( "checkPrepared" ) ) ;
9- var forNodeWebkit = require ( "for-node-webkit " ) ;
9+ var whichNativeNodish = require ( "which-native-nodish " ) ;
1010var prepareForBuild = require ( local ( "prepareForBuild" ) ) ;
1111
1212var exec = promisify ( function ( command , opts , callback ) {
1313 return require ( "child_process" ) . exec ( command , opts , callback ) ;
1414} ) ;
15+ var nwVersion = null ;
16+ var asVersion = null ;
1517
16- return forNodeWebkit ( local ( ".." ) )
18+ return whichNativeNodish ( local ( ".." ) )
1719 . then ( function ( results ) {
18- return results . nwVersion ;
20+ nwVersion = results . nwVersion ;
21+ asVersion = results . asVersion ;
1922 } )
20- . then ( function ( nodeWebkitVersion ) {
21- if ( nodeWebkitVersion ) {
22- console . info ( "[nodegit] Must build for node-webkit" ) ;
23- return checkAndBuild ( nodeWebkitVersion ) ;
23+ . then ( function ( ) {
24+ if ( nwVersion ) {
25+ console . info ( "[nodegit] Must build for node-webkit/nw.js" ) ;
26+ return checkAndBuild ( ) ;
27+ }
28+ else if ( asVersion ) {
29+ console . info ( "[nodegit] Must build for atom-shell" ) ;
30+ return checkAndBuild ( ) ;
2431 }
2532 if ( fs . existsSync ( local ( "../.didntcomefromthenpmregistry" ) ) ) {
2633 return checkAndBuild ( ) ;
@@ -48,7 +55,7 @@ return forNodeWebkit(local(".."))
4855 } ) ;
4956
5057
51- function checkAndBuild ( nwVersion ) {
58+ function checkAndBuild ( ) {
5259 console . info ( "[nodegit] Making sure dependencies are available and native " +
5360 "code is generated" ) ;
5461
@@ -64,11 +71,11 @@ function checkAndBuild(nwVersion) {
6471 }
6572 } )
6673 . then ( function ( ) {
67- return build ( nwVersion ) ;
74+ return build ( ) ;
6875 } ) ;
6976}
7077
71- function build ( nwVersion ) {
78+ function build ( ) {
7279 console . info ( "[nodegit] Everything is ready to go, attempting compilation" ) ;
7380 if ( nwVersion ) {
7481 console . info ( "[nodegit] Building native node-webkit module." ) ;
@@ -82,14 +89,30 @@ function build(nwVersion) {
8289 maxBuffer : Number . MAX_VALUE
8390 } ;
8491
85- var builder = nwVersion ? "nw-gyp" : "node-gyp ";
86- var target = ( nwVersion ? "--target=\"" + nwVersion + "\"" : "" ) ;
92+ var prefix = " ";
93+ var target = "" ;
8794 var debug = ( process . env . BUILD_DEBUG ? " --debug" : "" ) ;
88- var cmd = path . resolve ( "." , "node_modules" , ".bin" , builder ) +
89- " clean configure" +
90- debug +
91- target +
92- " build" ;
95+ var builder = "node-gyp" ;
96+ var distUrl = "" ;
97+
98+ if ( asVersion ) {
99+ prefix = ( process . platform == "win32" ?
100+ "SET HOME=\"~/.atom-shell-gyp\" && " :
101+ "HOME=~/.atom-shell-gyp" ) ;
102+
103+ target = "--target=" + asVersion ;
104+
105+ distUrl = "--dist-url=https://gh-contractor-zcbenz.s3." +
106+ "amazonaws.com/atom-shell/dist" ;
107+ }
108+ else if ( nwVersion ) {
109+ builder = "nw-gyp" ;
110+ target = "--target=" + nwVersion ;
111+ }
112+
113+ builder = path . resolve ( "." , "node_modules" , ".bin" , builder ) ;
114+ var cmd = [ prefix , builder , "rebuild" , target , debug , distUrl ]
115+ . join ( " " ) . trim ( ) ;
93116
94117 return exec ( cmd , opts )
95118 . then ( function ( ) {
0 commit comments