Files
openpanel/packages/cli/src/utils/os/index.ts
Stefan Pejcic 8595a9f4e5 back
2024-05-08 19:58:53 +02:00

26 lines
564 B
TypeScript

import envinfo from "envinfo";
import os from "os";
export const getOSType = () => {
const osPlatform = os.type();
const types: Record<string, "macOS" | "Linux" | "Windows"> = {
Darwin: "macOS",
Linux: "Linux",
Windows_NT: "Windows",
};
return types[osPlatform];
};
export const getOS = async () => {
// returns as a ['OS', 'macOS Mojave 10.14.5']
const [_, OSInfo] =
(await envinfo.helpers.getOSInfo()) as unknown as string[];
return {
name: getOSType(),
version: OSInfo,
};
};