Skip to content

Commit

Permalink
fix: make install-app-deps also handle skip build flag
Browse files Browse the repository at this point in the history
Closes #797
  • Loading branch information
develar committed Oct 6, 2016
1 parent 106eea7 commit 3e34110
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function main() {
throw new Error("install-app-deps is only useful for two package.json structure")
}

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

main()
Expand Down
4 changes: 2 additions & 2 deletions src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ export class Packager implements BuildInfo {
log("Skip app dependencies rebuild because npmRebuild is set to false")
}
else if (platform.nodeName === process.platform) {
let doSourceBuild = !(this.devMetadata.build.npmSkipBuildFromSource === true)
await installDependencies(this.appDir, this.electronVersion, Arch[arch], (await statOrNull(path.join(this.appDir, "node_modules"))) == null ? "install" : "rebuild", doSourceBuild)
const forceBuildFromSource = this.devMetadata.build.npmSkipBuildFromSource !== true
await installDependencies(this.appDir, this.electronVersion, Arch[arch], forceBuildFromSource, (await statOrNull(path.join(this.appDir, "node_modules"))) == null ? "install" : "rebuild")
}
else {
log("Skip app dependencies rebuild because platform is different")
Expand Down
10 changes: 5 additions & 5 deletions src/util/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const debug7z = debugFactory("electron-builder:7z")

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

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

export function getGypEnv(electronVersion: string, arch: string): any {
Expand All @@ -32,17 +32,17 @@ export function getGypEnv(electronVersion: string, arch: string): any {
})
}

export function spawnNpmProduction(command: string, appDir: string, env?: any, forceBuild: boolean = true): BluebirdPromise<any> {
export function spawnNpmProduction(command: string, appDir: string, forceBuildFromSource: boolean, env?: any): BluebirdPromise<any> {
let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
let npmExecArgs = [command, "--production", "--cache-min", "999999999"]
const npmExecArgs = [command, "--production", "--cache-min", "999999999"]
if (npmExecPath == null) {
npmExecPath = process.platform === "win32" ? "npm.cmd" : "npm"
}
else {
npmExecArgs.unshift(npmExecPath)
npmExecPath = process.env.npm_node_execpath || process.env.NODE_EXE || "node"
}
if (forceBuild) {
if (forceBuildFromSource) {
npmExecArgs.push("--build-from-source")
}

Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO
if (projectDirCreated != null) {
await projectDirCreated(projectDir)
if (checkOptions.npmInstallBefore) {
await spawnNpmProduction("install", projectDir)
await spawnNpmProduction("install", projectDir, false)
}
}

Expand Down

0 comments on commit 3e34110

Please sign in to comment.