1
1
import * as electronRebuild from "@electron/rebuild"
2
- import { getProjectRootPath } from "@electron/rebuild/lib/search-module"
3
2
import { RebuildMode } from "@electron/rebuild/lib/types"
4
3
import { asArray , log , spawn } from "builder-util"
5
4
import { pathExists } from "fs-extra"
@@ -12,7 +11,7 @@ import { PM, detect, getPackageManagerVersion } from "../node-module-collector"
12
11
import { NodeModuleDirInfo } from "./packageDependencies"
13
12
import { rebuild as remoteRebuild } from "./rebuild/rebuild"
14
13
15
- export async function installOrRebuild ( config : Configuration , appDir : string , options : RebuildOptions , forceInstall = false ) {
14
+ export async function installOrRebuild ( config : Configuration , appDir : string , projectDir : string , options : RebuildOptions , forceInstall = false ) {
16
15
const effectiveOptions : RebuildOptions = {
17
16
buildFromSource : config . buildDependenciesFromSource === true ,
18
17
additionalArgs : asArray ( config . npmArgs ) ,
@@ -29,9 +28,9 @@ export async function installOrRebuild(config: Configuration, appDir: string, op
29
28
}
30
29
31
30
if ( forceInstall || ! isDependenciesInstalled ) {
32
- await installDependencies ( config , appDir , effectiveOptions )
31
+ await installDependencies ( config , appDir , projectDir , effectiveOptions )
33
32
} else {
34
- await rebuild ( config , appDir , effectiveOptions )
33
+ await rebuild ( config , appDir , projectDir , effectiveOptions )
35
34
}
36
35
}
37
36
@@ -91,12 +90,11 @@ async function checkYarnBerry(pm: PM) {
91
90
return version . split ( "." ) [ 0 ] >= "2"
92
91
}
93
92
94
- async function installDependencies ( config : Configuration , appDir : string , options : RebuildOptions ) : Promise < any > {
93
+ async function installDependencies ( config : Configuration , appDir : string , projectDir : string , options : RebuildOptions ) : Promise < any > {
95
94
const platform = options . platform || process . platform
96
95
const arch = options . arch || process . arch
97
96
const additionalArgs = options . additionalArgs
98
97
99
- const projectDir = await getProjectRootPath ( appDir )
100
98
const pm = await detect ( { cwd : projectDir } )
101
99
log . info ( { pm, platform, arch, projectDir, appDir } , `installing production dependencies` )
102
100
const execArgs = [ "install" ]
@@ -123,7 +121,7 @@ async function installDependencies(config: Configuration, appDir: string, option
123
121
124
122
// Some native dependencies no longer use `install` hook for building their native module, (yarn 3+ removed implicit link of `install` and `rebuild` steps)
125
123
// https://github.com/electron-userland/electron-builder/issues/8024
126
- return rebuild ( config , appDir , options )
124
+ return rebuild ( config , appDir , projectDir , options )
127
125
}
128
126
129
127
export async function nodeGypRebuild ( platform : NodeJS . Platform , arch : string , frameworkInfo : DesktopFrameworkInfo ) {
@@ -171,7 +169,7 @@ export interface RebuildOptions {
171
169
}
172
170
173
171
/** @internal */
174
- export async function rebuild ( config : Configuration , appDir : string , options : RebuildOptions ) {
172
+ export async function rebuild ( config : Configuration , appDir : string , projectDir : string , options : RebuildOptions ) {
175
173
const configuration = {
176
174
dependencies : await options . productionDeps . value ,
177
175
nodeExecPath : process . execPath ,
@@ -205,7 +203,7 @@ export async function rebuild(config: Configuration, appDir: string, options: Re
205
203
arch,
206
204
platform,
207
205
buildFromSource,
208
- projectRootPath : await getProjectRootPath ( appDir ) ,
206
+ projectRootPath : projectDir ,
209
207
mode : ( config . nativeRebuilder as RebuildMode ) || "sequential" ,
210
208
disablePreGypCopy : true ,
211
209
}
0 commit comments