Skip to content

Commit

Permalink
fix(mac): use uname -a to get arch before testing 'process.arch' on…
Browse files Browse the repository at this point in the history
… mac silicon (#6381)
  • Loading branch information
zhanjinfeng authored Nov 30, 2021
1 parent b9473e2 commit 828fcd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/new-shirts-invent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix: use `uname -a` to get arch instead of 'process.arch' in mac silicon
13 changes: 12 additions & 1 deletion packages/electron-updater/src/MacUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +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
let isArm64Mac = false
try {
this.debug("Checking for arm64 in uname")
const result = execFileSync("uname", ['-a'], { encoding: "utf8" })
const isArm = result.includes('ARM')
log.info(`Checked 'uname -a': arm64=${isArm}`)
isArm64Mac = isArm64Mac || isArm
} catch (e) {
log.warn(`uname shell command to check for arm64 failed: ${e}`)
}

isArm64Mac = 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")
Expand Down

0 comments on commit 828fcd3

Please sign in to comment.