43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
export var Platform;
|
|
(function (Platform) {
|
|
Platform[Platform["Web"] = 0] = "Web";
|
|
Platform[Platform["Mac"] = 1] = "Mac";
|
|
Platform[Platform["Linux"] = 2] = "Linux";
|
|
Platform[Platform["Windows"] = 3] = "Windows";
|
|
})(Platform || (Platform = {}));
|
|
let _isWindows = false;
|
|
let _isMacintosh = false;
|
|
let _isLinux = false;
|
|
let _isRootUser = false;
|
|
let _isNative = false;
|
|
let _isWeb = false;
|
|
let _isQunit = false;
|
|
export let _platform = Platform.Web;
|
|
// OS detection
|
|
if (typeof process === 'object') {
|
|
_isWindows = (process.platform === 'win32');
|
|
_isMacintosh = (process.platform === 'darwin');
|
|
_isLinux = (process.platform === 'linux');
|
|
_isRootUser = !_isWindows && (process.getuid() === 0);
|
|
_isNative = true;
|
|
}
|
|
if (_isNative) {
|
|
if (_isMacintosh) {
|
|
_platform = Platform.Mac;
|
|
}
|
|
else if (_isWindows) {
|
|
_platform = Platform.Windows;
|
|
}
|
|
else if (_isLinux) {
|
|
_platform = Platform.Linux;
|
|
}
|
|
}
|
|
export const isWindows = _isWindows;
|
|
export const isMacintosh = _isMacintosh;
|
|
export const isLinux = _isLinux;
|
|
export const isRootUser = _isRootUser;
|
|
export const isNative = _isNative;
|
|
export const isWeb = _isWeb;
|
|
export const isQunit = _isQunit;
|
|
export const platform = _platform;
|