@@ -3,8 +3,10 @@ import { pathExists } from "fs-extra"
3
3
import { homedir } from "os"
4
4
import * as path from "path"
5
5
import { Configuration } from "../configuration"
6
- import * as electronRebuild from "@electron/rebuild"
6
+ import * as electronRebuild from "@electron/rebuild/lib/rebuild "
7
7
import * as searchModule from "@electron/rebuild/lib/search-module"
8
+ import { EventEmitter } from "events"
9
+ import { Platform } from "../core"
8
10
9
11
export async function installOrRebuild ( config : Configuration , appDir : string , options : RebuildOptions , forceInstall = false ) {
10
12
let isDependenciesInstalled = false
@@ -24,7 +26,8 @@ export async function installOrRebuild(config: Configuration, appDir: string, op
24
26
await installDependencies ( appDir , effectiveOptions )
25
27
} else {
26
28
const arch = archFromString ( options . arch || process . arch )
27
- await rebuild ( appDir , config . buildDependenciesFromSource === true , options . frameworkInfo , arch )
29
+ const platform = Platform . fromString ( options . platform || process . platform )
30
+ await rebuild ( appDir , config . buildDependenciesFromSource === true , options . frameworkInfo , arch , platform )
28
31
}
29
32
}
30
33
@@ -117,8 +120,8 @@ function installDependencies(appDir: string, options: RebuildOptions): Promise<a
117
120
} )
118
121
}
119
122
120
- export async function nodeGypRebuild ( frameworkInfo : DesktopFrameworkInfo , arch : Arch ) {
121
- return rebuild ( process . cwd ( ) , false , frameworkInfo , arch )
123
+ export async function nodeGypRebuild ( frameworkInfo : DesktopFrameworkInfo , arch : Arch , platform : Platform ) {
124
+ return rebuild ( process . cwd ( ) , false , frameworkInfo , arch , platform )
122
125
}
123
126
124
127
function getPackageToolPath ( ) {
@@ -146,18 +149,21 @@ export interface RebuildOptions {
146
149
}
147
150
148
151
/** @internal */
149
- export async function rebuild ( appDir : string , buildFromSource : boolean , frameworkInfo : DesktopFrameworkInfo , arch : Arch ) {
150
- log . info ( { arch : Arch [ arch ] , version : frameworkInfo . version , appDir } , "executing @electron/rebuild" )
152
+ export async function rebuild ( appDir : string , buildFromSource : boolean , frameworkInfo : DesktopFrameworkInfo , arch : Arch , platform : Platform ) {
153
+ log . info ( { arch : Arch [ arch ] , platform : platform . name , version : frameworkInfo . version , appDir } , "executing @electron/rebuild" )
151
154
const rootPath = await searchModule . getProjectRootPath ( appDir )
152
- const options : electronRebuild . RebuildOptions = {
155
+ const rebuilderOptions : electronRebuild . RebuilderOptions = {
153
156
buildPath : appDir ,
154
157
electronVersion : frameworkInfo . version ,
155
158
arch : Arch [ arch ] ,
156
159
projectRootPath : rootPath ,
157
160
disablePreGypCopy : true ,
161
+ lifecycle : new EventEmitter ( ) ,
158
162
}
159
163
if ( buildFromSource ) {
160
- options . prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"
164
+ rebuilderOptions . prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"
161
165
}
162
- return electronRebuild . rebuild ( options )
166
+ const rebuilder = new electronRebuild . Rebuilder ( rebuilderOptions )
167
+ rebuilder . platform = platform . nodeName
168
+ return rebuilder . rebuild ( )
163
169
}
0 commit comments