UNPKG

2.4 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2017 TypeFox and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.OS = exports.cmd = exports.isOSX = exports.isWindows = void 0;
19function is(userAgent, platform) {
20 if (typeof navigator !== 'undefined') {
21 if (navigator.userAgent && navigator.userAgent.indexOf(userAgent) >= 0) {
22 return true;
23 }
24 }
25 if (typeof process !== 'undefined') {
26 return (process.platform === platform);
27 }
28 return false;
29}
30exports.isWindows = is('Windows', 'win32');
31exports.isOSX = is('Mac', 'darwin');
32function cmd(command, ...args) {
33 return [
34 exports.isWindows ? 'cmd' : command,
35 exports.isWindows ? ['/c', command, ...args] : args
36 ];
37}
38exports.cmd = cmd;
39var OS;
40(function (OS) {
41 /**
42 * Enumeration of the supported operating systems.
43 */
44 let Type;
45 (function (Type) {
46 Type["Windows"] = "Windows";
47 Type["Linux"] = "Linux";
48 Type["OSX"] = "OSX";
49 })(Type = OS.Type || (OS.Type = {}));
50 /**
51 * Returns with the type of the operating system. If it is neither [Windows](isWindows) nor [OS X](isOSX), then
52 * it always return with the `Linux` OS type.
53 */
54 function type() {
55 if (exports.isWindows) {
56 return Type.Windows;
57 }
58 if (exports.isOSX) {
59 return Type.OSX;
60 }
61 return Type.Linux;
62 }
63 OS.type = type;
64 OS.backend = {
65 type,
66 isWindows: exports.isWindows,
67 isOSX: exports.isOSX
68 };
69})(OS = exports.OS || (exports.OS = {}));
70//# sourceMappingURL=os.js.map
\No newline at end of file