fix: download the arm64 version of Electron when running node under rosetta (#29953)
This commit is contained in:
parent
f3517b6635
commit
7169734470
1 changed files with 19 additions and 2 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
const { version } = require('./package');
|
const { version } = require('./package');
|
||||||
|
|
||||||
|
const childProcess = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
@ -18,14 +19,30 @@ if (isInstalled()) {
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const platform = process.env.npm_config_platform || process.platform;
|
||||||
|
let arch = process.env.npm_config_arch || process.arch;
|
||||||
|
|
||||||
|
if (platform === 'darwin' && process.platform === 'darwin' && arch === 'x64') {
|
||||||
|
// When downloading for macOS ON macOS and we think we need x64 we should
|
||||||
|
// check if we're running under rosetta and download the arm64 version if appropriate
|
||||||
|
try {
|
||||||
|
const output = childProcess.execSync('sysctl -in sysctl.proc_translated');
|
||||||
|
if (output.toString().trim() === '1') {
|
||||||
|
arch = 'arm64';
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Ignore failure
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// downloads if not cached
|
// downloads if not cached
|
||||||
downloadArtifact({
|
downloadArtifact({
|
||||||
version,
|
version,
|
||||||
artifactName: 'electron',
|
artifactName: 'electron',
|
||||||
force: process.env.force_no_cache === 'true',
|
force: process.env.force_no_cache === 'true',
|
||||||
cacheRoot: process.env.electron_config_cache,
|
cacheRoot: process.env.electron_config_cache,
|
||||||
platform: process.env.npm_config_platform || process.platform,
|
platform,
|
||||||
arch: process.env.npm_config_arch || process.arch
|
arch
|
||||||
}).then(extractFile).catch(err => {
|
}).then(extractFile).catch(err => {
|
||||||
console.error(err.stack);
|
console.error(err.stack);
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue