esa-cli
Version:
A CLI for operating Alibaba Cloud ESA EdgeRoutine (Edge Functions).
33 lines (32 loc) • 926 B
JavaScript
import os from 'os';
export var Platforms;
(function (Platforms) {
Platforms["Win"] = "win";
Platforms["AppleArm"] = "darwin-arm64";
Platforms["AppleIntel"] = "darwin-x86_64";
Platforms["LinuxX86"] = "linux-x86_64";
Platforms["Linux"] = "linux";
Platforms["others"] = "others";
})(Platforms || (Platforms = {}));
export const checkOS = () => {
const platform = os.platform();
const cpus = os.cpus();
const cpuModel = cpus[0].model.toLowerCase();
const arch = os.arch();
if (platform === 'win32') {
return Platforms.Win;
}
if (platform === 'darwin') {
if (cpuModel.includes('apple')) {
return Platforms.AppleArm;
}
return Platforms.AppleIntel;
}
if (platform === 'linux') {
if (arch === 'x64') {
return Platforms.LinuxX86;
}
return Platforms.Linux;
}
return Platforms.others;
};