2023-01-03 11:55:46 -08:00
|
|
|
// Copyright 2018 Signal Messenger, LLC
|
2020-10-30 15:34:04 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2023-01-18 15:31:10 -08:00
|
|
|
import { release as osRelease } from 'os';
|
2018-05-02 19:57:02 -04:00
|
|
|
import semver from 'semver';
|
|
|
|
|
2023-01-18 15:31:10 -08:00
|
|
|
const createIsPlatform = (
|
|
|
|
platform: typeof process.platform
|
|
|
|
): ((minVersion?: string) => boolean) => {
|
|
|
|
return minVersion => {
|
|
|
|
if (process.platform !== platform) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (minVersion === undefined) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-05-02 19:57:02 -04:00
|
|
|
|
2023-01-18 15:31:10 -08:00
|
|
|
return semver.gte(osRelease(), minVersion);
|
|
|
|
};
|
2018-05-02 19:57:02 -04:00
|
|
|
};
|
2022-07-05 09:44:53 -07:00
|
|
|
|
2023-01-18 15:31:10 -08:00
|
|
|
export const isMacOS = createIsPlatform('darwin');
|
|
|
|
export const isLinux = createIsPlatform('linux');
|
|
|
|
export const isWindows = createIsPlatform('win32');
|
|
|
|
|
2022-07-05 09:44:53 -07:00
|
|
|
// Windows 10 and above
|
|
|
|
export const hasCustomTitleBar = (): boolean =>
|
|
|
|
isWindows('10.0.0') || Boolean(process.env.CUSTOM_TITLEBAR);
|
2023-01-18 15:31:10 -08:00
|
|
|
|
|
|
|
export const getName = (): string => {
|
|
|
|
if (isMacOS()) {
|
|
|
|
return 'macOS';
|
|
|
|
}
|
|
|
|
if (isWindows()) {
|
|
|
|
return 'Windows';
|
|
|
|
}
|
|
|
|
return 'Linux';
|
|
|
|
};
|
2023-02-23 13:32:19 -08:00
|
|
|
|
|
|
|
export const getClassName = (): string => {
|
|
|
|
if (isMacOS()) {
|
|
|
|
return 'os-macos';
|
|
|
|
}
|
|
|
|
if (isWindows()) {
|
|
|
|
return 'os-windows';
|
|
|
|
}
|
|
|
|
return 'os-linux';
|
|
|
|
};
|