Skip to content

Commit

Permalink
fix: latest node-gyp with old Electron versions (#6402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheng Zhao committed Nov 9, 2021
1 parent 9d9274e commit f41d5f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changeset/neat-buttons-press.md
@@ -0,0 +1,7 @@
---
"app-builder-lib": patch
---

fix: Since node-gyp >= 8.4.0, building modules for old versions of Electron requires passing --force-process-config due to them lacking a valid config.gypi in their headers.

See also nodejs/node-gyp#2497.
13 changes: 12 additions & 1 deletion packages/app-builder-lib/src/util/yarn.ts
Expand Up @@ -123,7 +123,18 @@ export async function nodeGypRebuild(platform: NodeJS.Platform, arch: string, fr
log.info({ platform, arch }, "executing node-gyp rebuild")
// this script must be used only for electron
const nodeGyp = `node-gyp${process.platform === "win32" ? ".cmd" : ""}`
await spawn(nodeGyp, ["rebuild"], { env: getGypEnv(frameworkInfo, platform, arch, true) })
const args = ["rebuild"]
// headers of old Electron versions do not have a valid config.gypi file
// and --force-process-config must be passed to node-gyp >= 8.4.0 to
// correctly build modules for them.
// see also https://github.com/nodejs/node-gyp/pull/2497
const [major, minor] = frameworkInfo.version.split('.').slice(0, 2).map(n => parseInt(n, 10))
if ((major <= 13) ||
(major == 14 && minor <= 1) ||
(major == 15 && minor <= 2)) {
args.push('--force-process-config')
}
await spawn(nodeGyp, args, { env: getGypEnv(frameworkInfo, platform, arch, true) })
}

function getPackageToolPath() {
Expand Down

0 comments on commit f41d5f3

Please sign in to comment.