Skip to content

Commit 3e34110

Browse files
committed
fix: make install-app-deps also handle skip build flag
Closes #797
1 parent 106eea7 commit 3e34110

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/install-app-deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ async function main() {
3030
throw new Error("install-app-deps is only useful for two package.json structure")
3131
}
3232

33-
await installDependencies(results[0], results[1], args.arch)
33+
await installDependencies(results[0], results[1], args.arch, devMetadata.build.npmSkipBuildFromSource !== true)
3434
}
3535

3636
main()

src/packager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ export class Packager implements BuildInfo {
235235
log("Skip app dependencies rebuild because npmRebuild is set to false")
236236
}
237237
else if (platform.nodeName === process.platform) {
238-
let doSourceBuild = !(this.devMetadata.build.npmSkipBuildFromSource === true)
239-
await installDependencies(this.appDir, this.electronVersion, Arch[arch], (await statOrNull(path.join(this.appDir, "node_modules"))) == null ? "install" : "rebuild", doSourceBuild)
238+
const forceBuildFromSource = this.devMetadata.build.npmSkipBuildFromSource !== true
239+
await installDependencies(this.appDir, this.electronVersion, Arch[arch], forceBuildFromSource, (await statOrNull(path.join(this.appDir, "node_modules"))) == null ? "install" : "rebuild")
240240
}
241241
else {
242242
log("Skip app dependencies rebuild because platform is different")

src/util/util.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ export const debug7z = debugFactory("electron-builder:7z")
1616

1717
const DEFAULT_APP_DIR_NAMES = ["app", "www"]
1818

19-
export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, command: string = "install", fromSource: boolean = true): BluebirdPromise<any> {
20-
return task(`${(command === "install" ? "Installing" : "Rebuilding")} app dependencies for arch ${arch} to ${appDir}`, spawnNpmProduction(command, appDir, getGypEnv(electronVersion, arch), fromSource))
19+
export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, forceBuildFromSource: boolean, command: string = "install"): BluebirdPromise<any> {
20+
return task(`${(command === "install" ? "Installing" : "Rebuilding")} app dependencies for arch ${arch} to ${appDir}`, spawnNpmProduction(command, appDir, forceBuildFromSource, getGypEnv(electronVersion, arch)))
2121
}
2222

2323
export function getGypEnv(electronVersion: string, arch: string): any {
@@ -32,17 +32,17 @@ export function getGypEnv(electronVersion: string, arch: string): any {
3232
})
3333
}
3434

35-
export function spawnNpmProduction(command: string, appDir: string, env?: any, forceBuild: boolean = true): BluebirdPromise<any> {
35+
export function spawnNpmProduction(command: string, appDir: string, forceBuildFromSource: boolean, env?: any): BluebirdPromise<any> {
3636
let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
37-
let npmExecArgs = [command, "--production", "--cache-min", "999999999"]
37+
const npmExecArgs = [command, "--production", "--cache-min", "999999999"]
3838
if (npmExecPath == null) {
3939
npmExecPath = process.platform === "win32" ? "npm.cmd" : "npm"
4040
}
4141
else {
4242
npmExecArgs.unshift(npmExecPath)
4343
npmExecPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
4444
}
45-
if (forceBuild) {
45+
if (forceBuildFromSource) {
4646
npmExecArgs.push("--build-from-source")
4747
}
4848

test/src/helpers/packTester.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO
9595
if (projectDirCreated != null) {
9696
await projectDirCreated(projectDir)
9797
if (checkOptions.npmInstallBefore) {
98-
await spawnNpmProduction("install", projectDir)
98+
await spawnNpmProduction("install", projectDir, false)
9999
}
100100
}
101101

0 commit comments

Comments
 (0)