1
0
mirror of https://github.com/jiahaog/Nativefier synced 2024-06-29 08:00:47 +02:00
Nativefier/src/infer/inferOs.ts
Cassidy James Blaede 1c06af23fa
inferOs: Add support for arm64 (#1037)
Tested on a Pinebook Pro running elementary OS
2020-08-29 16:12:22 -04:00

28 lines
680 B
TypeScript

import * as os from 'os';
import * as log from 'loglevel';
export function inferPlatform(): string {
const platform = os.platform();
if (
platform === 'darwin' ||
// @ts-ignore
platform === 'mas' ||
platform === 'win32' ||
platform === 'linux'
) {
log.debug('Inferred platform', platform);
return platform;
}
throw new Error(`Untested platform ${platform} detected`);
}
export function inferArch(): string {
const arch = os.arch();
if (arch !== 'ia32' && arch !== 'x64' && arch !== 'arm' && arch !== 'arm64') {
throw new Error(`Incompatible architecture ${arch} detected`);
}
log.debug('Inferred arch', arch);
return arch;
}