Skip to content

Commit feb79ef

Browse files
committed
fix: utilizing frameworkInfo as primary manner of fetching electron version for installation. (fixes: #7494)
1 parent e91989c commit feb79ef

File tree

4 files changed

+18
-11
lines changed

4 files changed

+18
-11
lines changed

.changeset/new-cats-cross.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"app-builder-lib": patch
3+
"electron-builder": patch
4+
---
5+
6+
fix: utilizing frameworkInfo as primary manner of fetching electron version for installation. (fixes: #7494)

packages/app-builder-lib/src/packager.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ export class Packager {
495495
const frameworkInfo = { version: this.framework.version, useCustomDist: true }
496496
const config = this.config
497497
if (config.nodeGypRebuild === true) {
498-
await nodeGypRebuild(Arch[arch])
498+
await nodeGypRebuild(frameworkInfo, Arch[arch])
499499
}
500500

501501
if (config.npmRebuild === false) {

packages/app-builder-lib/src/util/yarn.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { homedir } from "os"
55
import * as path from "path"
66
import { Configuration } from "../configuration"
77
import { NodeModuleDirInfo } from "./packageDependencies"
8-
import { getElectronVersion } from "../electron/electronVersion"
98
import * as electronRebuild from "@electron/rebuild"
109
import * as searchModule from "@electron/rebuild/lib/src/search-module"
1110

@@ -26,7 +25,7 @@ export async function installOrRebuild(config: Configuration, appDir: string, op
2625
}
2726
await installDependencies(appDir, effectiveOptions)
2827
} else {
29-
await rebuild(appDir, config.buildDependenciesFromSource === true, options.arch)
28+
await rebuild(appDir, config.buildDependenciesFromSource === true, options.frameworkInfo, options.arch)
3029
}
3130
}
3231

@@ -119,8 +118,8 @@ function installDependencies(appDir: string, options: RebuildOptions): Promise<a
119118
})
120119
}
121120

122-
export async function nodeGypRebuild(arch: string) {
123-
return rebuild(process.cwd(), false, arch)
121+
export async function nodeGypRebuild(frameworkInfo: DesktopFrameworkInfo, arch: string) {
122+
return rebuild(process.cwd(), false, frameworkInfo, arch)
124123
}
125124

126125
function getPackageToolPath() {
@@ -149,15 +148,15 @@ export interface RebuildOptions {
149148
}
150149

151150
/** @internal */
152-
export async function rebuild(appDir: string, buildFromSource: boolean, arch = process.arch) {
153-
log.info({ appDir, arch }, "executing @electron/rebuild")
151+
export async function rebuild(appDir: string, buildFromSource: boolean, frameworkInfo: DesktopFrameworkInfo, arch = process.arch) {
152+
log.info({ appDir, ...frameworkInfo }, "executing @electron/rebuild")
153+
const rootPath = await searchModule.getProjectRootPath(appDir)
154154
const options: electronRebuild.RebuildOptions = {
155155
buildPath: appDir,
156-
electronVersion: await getElectronVersion(appDir),
156+
electronVersion: frameworkInfo.version,
157157
arch,
158-
force: true,
159158
debug: log.isDebugEnabled,
160-
projectRootPath: await searchModule.getProjectRootPath(appDir),
159+
projectRootPath: rootPath,
161160
}
162161
if (buildFromSource) {
163162
options.prebuildTagPrefix = "totally-not-a-real-prefix-to-force-rebuild"

packages/electron-builder/src/cli/cli.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { createSelfSignedCert } from "./create-self-signed-cert"
1212
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"
1313
import { start } from "./start"
1414
import { nodeGypRebuild } from "app-builder-lib/out/util/yarn"
15+
import { getElectronVersion } from "app-builder-lib/out/electron/electronVersion"
1516

1617
// tslint:disable:no-unused-expression
1718
void createYargs()
@@ -75,6 +76,7 @@ async function checkIsOutdated() {
7576
}
7677

7778
async function rebuildAppNativeCode(args: any) {
79+
const projectDir = process.cwd()
7880
// this script must be used only for electron
79-
return nodeGypRebuild(args.arch)
81+
return nodeGypRebuild({ version: await getElectronVersion(projectDir), useCustomDist: true }, args.arch)
8082
}

0 commit comments

Comments
 (0)