@@ -6,31 +6,32 @@ import { spawn, asArray } from "./util/util"
6
6
import { BuildMetadata } from "./metadata"
7
7
import { exists } from "./util/fs"
8
8
9
- export async function installOrRebuild ( options : BuildMetadata , appDir : string , electronVersion : string , arch : string , forceInstall : boolean = false ) {
9
+ export async function installOrRebuild ( options : BuildMetadata , appDir : string , electronVersion : string , platform : string , arch : string , forceInstall : boolean = false ) {
10
10
const args = asArray ( options . npmArgs )
11
11
if ( forceInstall || ! ( await exists ( path . join ( appDir , "node_modules" ) ) ) ) {
12
- await installDependencies ( appDir , electronVersion , arch , args , ! options . npmSkipBuildFromSource )
12
+ await installDependencies ( appDir , electronVersion , platform , arch , args , ! options . npmSkipBuildFromSource )
13
13
}
14
14
else {
15
- await rebuild ( appDir , electronVersion , arch , args , ! options . npmSkipBuildFromSource )
15
+ await rebuild ( appDir , electronVersion , arch , platform , args , ! options . npmSkipBuildFromSource )
16
16
}
17
17
}
18
18
19
- export function getGypEnv ( electronVersion : string , arch : string , buildFromSource : boolean ) {
19
+ export function getGypEnv ( electronVersion : string , platform : string , arch : string , buildFromSource : boolean ) {
20
20
const gypHome = path . join ( homedir ( ) , ".electron-gyp" )
21
21
return Object . assign ( { } , process . env , {
22
22
npm_config_disturl : "https://atom.io/download/electron" ,
23
23
npm_config_target : electronVersion ,
24
24
npm_config_runtime : "electron" ,
25
25
npm_config_arch : arch ,
26
26
npm_config_target_arch : arch ,
27
+ npm_config_platform : platform ,
27
28
npm_config_build_from_source : buildFromSource ,
28
29
HOME : gypHome ,
29
30
USERPROFILE : gypHome ,
30
31
} )
31
32
}
32
33
33
- export function installDependencies ( appDir : string , electronVersion : string , arch : string = process . arch , additionalArgs : Array < string > , buildFromSource : boolean ) : Promise < any > {
34
+ function installDependencies ( appDir : string , electronVersion : string , platform : string = process . platform , arch : string = process . arch , additionalArgs : Array < string > , buildFromSource : boolean ) : Promise < any > {
34
35
log ( `Installing app dependencies for arch ${ arch } to ${ appDir } ` )
35
36
let execPath = process . env . npm_execpath || process . env . NPM_CLI_JS
36
37
const execArgs = [ "install" , "--production" ]
@@ -54,7 +55,7 @@ export function installDependencies(appDir: string, electronVersion: string, arc
54
55
execArgs . push ( ...additionalArgs )
55
56
return spawn ( execPath , execArgs , {
56
57
cwd : appDir ,
57
- env : getGypEnv ( electronVersion , arch , buildFromSource ) ,
58
+ env : getGypEnv ( electronVersion , arch , platform , buildFromSource ) ,
58
59
} )
59
60
}
60
61
@@ -109,16 +110,17 @@ function isYarnPath(execPath: string | null) {
109
110
return execPath != null && path . basename ( execPath ) . startsWith ( "yarn" )
110
111
}
111
112
112
- export async function rebuild ( appDir : string , electronVersion : string , arch : string = process . arch , additionalArgs : Array < string > , buildFromSource : boolean ) {
113
+ export async function rebuild ( appDir : string , electronVersion : string , arch : string = process . arch , platform : string = process . platform , additionalArgs : Array < string > , buildFromSource : boolean ) {
113
114
const deps = new Set < string > ( )
114
115
await dependencies ( appDir , false , deps )
115
116
const nativeDeps = await BluebirdPromise . filter ( deps , it => exists ( path . join ( it , "binding.gyp" ) ) , { concurrency : 8 } )
116
117
117
118
if ( nativeDeps . length === 0 ) {
119
+ log ( `No native production dependencies` )
118
120
return
119
121
}
120
122
121
- log ( `Rebuilding native production dependencies for arch ${ arch } ` )
123
+ log ( `Rebuilding native production dependencies for ${ platform } : ${ arch } ` )
122
124
123
125
let execPath = process . env . npm_execpath || process . env . NPM_CLI_JS
124
126
const isYarn = isYarnPath ( execPath )
@@ -131,7 +133,7 @@ export async function rebuild(appDir: string, electronVersion: string, arch: str
131
133
execPath = process . env . npm_node_execpath || process . env . NODE_EXE || "node"
132
134
}
133
135
134
- const env = getGypEnv ( electronVersion , arch , buildFromSource )
136
+ const env = getGypEnv ( electronVersion , arch , platform , buildFromSource )
135
137
if ( isYarn ) {
136
138
execArgs . push ( "run" , "install" , "--" )
137
139
execArgs . push ( ...additionalArgs )
0 commit comments