UNPKG

2.17 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.DIR_TARGET = exports.DEFAULT_TARGET = exports.Target = exports.Platform = void 0;
4const builder_util_1 = require("builder-util");
5class Platform {
6 constructor(name, buildConfigurationKey, nodeName) {
7 this.name = name;
8 this.buildConfigurationKey = buildConfigurationKey;
9 this.nodeName = nodeName;
10 }
11 toString() {
12 return this.name;
13 }
14 createTarget(type, ...archs) {
15 if (type == null && (archs == null || archs.length === 0)) {
16 return new Map([[this, new Map()]]);
17 }
18 const archToType = new Map();
19 for (const arch of archs == null || archs.length === 0 ? [(0, builder_util_1.archFromString)(process.arch)] : archs) {
20 archToType.set(arch, type == null ? [] : Array.isArray(type) ? type : [type]);
21 }
22 return new Map([[this, archToType]]);
23 }
24 static current() {
25 return Platform.fromString(process.platform);
26 }
27 static fromString(name) {
28 name = name.toLowerCase();
29 switch (name) {
30 case Platform.MAC.nodeName:
31 case Platform.MAC.name:
32 return Platform.MAC;
33 case Platform.WINDOWS.nodeName:
34 case Platform.WINDOWS.name:
35 case Platform.WINDOWS.buildConfigurationKey:
36 return Platform.WINDOWS;
37 case Platform.LINUX.nodeName:
38 return Platform.LINUX;
39 default:
40 throw new Error(`Unknown platform: ${name}`);
41 }
42 }
43}
44exports.Platform = Platform;
45Platform.MAC = new Platform("mac", "mac", "darwin");
46Platform.LINUX = new Platform("linux", "linux", "linux");
47Platform.WINDOWS = new Platform("windows", "win", "win32");
48class Target {
49 constructor(name, isAsyncSupported = true) {
50 this.name = name;
51 this.isAsyncSupported = isAsyncSupported;
52 }
53 async checkOptions() {
54 // ignore
55 }
56 finishBuild() {
57 return Promise.resolve();
58 }
59}
60exports.Target = Target;
61exports.DEFAULT_TARGET = "default";
62exports.DIR_TARGET = "dir";
63//# sourceMappingURL=core.js.map
\No newline at end of file