Skip to content

Commit

Permalink
fix: npm install doesn't rebuild native dependencies if arch changed …
Browse files Browse the repository at this point in the history
…— rebuild must be used
  • Loading branch information
develar committed Mar 10, 2016
1 parent 1ade5c2 commit 5bcc95a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ const devPackageFile = path.join(process.cwd(), "package.json")
const appDir = args.appDir || DEFAULT_APP_DIR_NAME

readPackageJson(devPackageFile)
.then(it => installDependencies(path.join(process.cwd(), appDir), args.arch, getElectronVersion(it, devPackageFile)))
.then(it => installDependencies(path.join(process.cwd(), appDir), getElectronVersion(it, devPackageFile), args.arch))
.catch(printErrorAndExit)
2 changes: 1 addition & 1 deletion src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export class Packager implements BuildInfo {

private installAppDependencies(arch: string): Promise<any> {
if (this.isTwoPackageJsonProjectLayoutUsed) {
return installDependencies(this.appDir, arch, this.electronVersion)
return installDependencies(this.appDir, this.electronVersion, arch, "rebuild")
}
else {
log("Skipping app dependencies installation because dev and app dependencies are not separated")
Expand Down
17 changes: 9 additions & 8 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { execFile, spawn as _spawn } from "child_process"
import { Promise as BluebirdPromise } from "bluebird"
import readPackageJsonAsync = require("read-package-json")
import * as os from "os"
import * as path from "path"

export const log = console.log

Expand All @@ -14,21 +16,20 @@ export const commonArgs: any[] = [{

export const readPackageJson = BluebirdPromise.promisify(readPackageJsonAsync)

export function installDependencies(appDir: string, arch: string, electronVersion: string): BluebirdPromise<any> {
log("Installing app dependencies for arch %s to %s", arch || process.arch, appDir)
export function installDependencies(appDir: string, electronVersion: string, arch: string = process.arch, command: string = "install"): BluebirdPromise<any> {
log("Installing app dependencies for arch %s to %s", arch, appDir)
const gypHome = path.join(os.homedir(), ".electron-gyp")
const env = Object.assign({}, process.env, {
npm_config_disturl: "https://atom.io/download/atom-shell",
npm_config_target: electronVersion,
npm_config_runtime: "electron",
HOME: require("os").homedir() + "/.electron-gyp",
npm_config_arch: arch,
HOME: gypHome,
USERPROFILE: gypHome,
})

if (arch != null) {
env.npm_config_arch = arch
}

let npmExecPath = process.env.npm_execpath || process.env.NPM_CLI_JS
const npmExecArgs = ["install"]
const npmExecArgs = [command, "--production"]
if (npmExecPath == null) {
npmExecPath = "npm"
}
Expand Down

0 comments on commit 5bcc95a

Please sign in to comment.