From 0c21cd69663a7eebe0687eaba9eea851cc2fea9e Mon Sep 17 00:00:00 2001 From: Johnny Opao <7469654+johnnyopao@users.noreply.github.com> Date: Wed, 1 Sep 2021 02:39:08 -0400 Subject: [PATCH] fix: (mac) Fix intel mac upgrade flow when both x64 and arm64 published (#6212) --- .changeset/lovely-coats-grow.md | 5 +++++ packages/electron-updater/src/MacUpdater.ts | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 .changeset/lovely-coats-grow.md diff --git a/.changeset/lovely-coats-grow.md b/.changeset/lovely-coats-grow.md new file mode 100644 index 00000000000..ad1d0d03cfb --- /dev/null +++ b/.changeset/lovely-coats-grow.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +Fix upgrade flows on intel mac when both x64 and arm64 versions published diff --git a/packages/electron-updater/src/MacUpdater.ts b/packages/electron-updater/src/MacUpdater.ts index 1e1cd209df7..ed9b6d73ed5 100644 --- a/packages/electron-updater/src/MacUpdater.ts +++ b/packages/electron-updater/src/MacUpdater.ts @@ -40,7 +40,7 @@ export class MacUpdater extends AppUpdater { // detect if we are running inside Rosetta emulation const sysctlRosettaInfoKey = "sysctl.proc_translated" - let isRosetta: boolean + let isRosetta = false try { this.debug("Checking for macOS Rosetta environment") const result = execFileSync("sysctl", [sysctlRosettaInfoKey], { encoding: "utf8" }) @@ -50,13 +50,18 @@ export class MacUpdater extends AppUpdater { log.warn(`sysctl shell command to check for macOS Rosetta environment failed: ${e}`) } + const isArm64Mac = process.arch === "arm64" || isRosetta + // allow arm64 macs to install universal or rosetta2(x64) - https://github.com/electron-userland/electron-builder/pull/5524 const isArm64 = (file: ResolvedUpdateFileInfo) => file.url.pathname.includes("arm64") || file.info.url?.includes("arm64") - if (files.some(isArm64)) { - files = files.filter(file => (process.arch === "arm64" || isRosetta) === isArm64(file)) + if (isArm64Mac && files.some(isArm64)) { + files = files.filter(file => isArm64Mac === isArm64(file)) + } else { + files = files.filter(file => !isArm64(file)) } const zipFileInfo = findFile(files, "zip", ["pkg", "dmg"]) + if (zipFileInfo == null) { throw newError(`ZIP file not provided: ${safeStringifyJson(files)}`, "ERR_UPDATER_ZIP_FILE_NOT_FOUND") }