Use electron API to detect Rosetta
This commit is contained in:
parent
9dc9808420
commit
a9395ddecc
1 changed files with 4 additions and 16 deletions
|
@ -5,8 +5,6 @@
|
||||||
import { createWriteStream } from 'fs';
|
import { createWriteStream } from 'fs';
|
||||||
import { pathExists } from 'fs-extra';
|
import { pathExists } from 'fs-extra';
|
||||||
import { readdir, stat, writeFile, mkdir } from 'fs/promises';
|
import { readdir, stat, writeFile, mkdir } from 'fs/promises';
|
||||||
import { promisify } from 'util';
|
|
||||||
import { execFile } from 'child_process';
|
|
||||||
import { join, normalize, extname } from 'path';
|
import { join, normalize, extname } from 'path';
|
||||||
import { tmpdir, release as osRelease } from 'os';
|
import { tmpdir, release as osRelease } from 'os';
|
||||||
import { throttle } from 'lodash';
|
import { throttle } from 'lodash';
|
||||||
|
@ -714,22 +712,12 @@ export abstract class Updater {
|
||||||
return process.arch;
|
return process.arch;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (app.runningUnderARM64Translation) {
|
||||||
// We might be running under Rosetta
|
this.logger.info('updater: running under arm64 translation');
|
||||||
const flag = 'sysctl.proc_translated';
|
return 'arm64';
|
||||||
const { stdout } = await promisify(execFile)('sysctl', ['-i', flag]);
|
|
||||||
|
|
||||||
if (stdout.includes(`${flag}: 1`)) {
|
|
||||||
this.logger.info('updater: running under Rosetta');
|
|
||||||
return 'arm64';
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
this.logger.warn(
|
|
||||||
`updater: Rosetta detection failed with ${Errors.toLogFormat(error)}`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logger.info('updater: not running under Rosetta');
|
this.logger.info('updater: not running under arm64 translation');
|
||||||
return process.arch;
|
return process.arch;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue