Unsupported OS Dialog
This commit is contained in:
parent
c6e184016b
commit
ac50af52d2
44 changed files with 776 additions and 224 deletions
37
ts/OS.ts
37
ts/OS.ts
|
@ -1,21 +1,38 @@
|
|||
// Copyright 2018 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import os from 'os';
|
||||
import { release as osRelease } from 'os';
|
||||
import semver from 'semver';
|
||||
|
||||
export const isMacOS = (): boolean => process.platform === 'darwin';
|
||||
export const isLinux = (): boolean => process.platform === 'linux';
|
||||
export const isWindows = (minVersion?: string): boolean => {
|
||||
const osRelease = os.release();
|
||||
const createIsPlatform = (
|
||||
platform: typeof process.platform
|
||||
): ((minVersion?: string) => boolean) => {
|
||||
return minVersion => {
|
||||
if (process.platform !== platform) {
|
||||
return false;
|
||||
}
|
||||
if (minVersion === undefined) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (process.platform !== 'win32') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return minVersion === undefined ? true : semver.gte(osRelease, minVersion);
|
||||
return semver.gte(osRelease(), minVersion);
|
||||
};
|
||||
};
|
||||
|
||||
export const isMacOS = createIsPlatform('darwin');
|
||||
export const isLinux = createIsPlatform('linux');
|
||||
export const isWindows = createIsPlatform('win32');
|
||||
|
||||
// Windows 10 and above
|
||||
export const hasCustomTitleBar = (): boolean =>
|
||||
isWindows('10.0.0') || Boolean(process.env.CUSTOM_TITLEBAR);
|
||||
|
||||
export const getName = (): string => {
|
||||
if (isMacOS()) {
|
||||
return 'macOS';
|
||||
}
|
||||
if (isWindows()) {
|
||||
return 'Windows';
|
||||
}
|
||||
return 'Linux';
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue