aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nexe/lib/target.js
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
commitd25e11bee6ca5ca523884da132d18e1400e077b9 (patch)
tree8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/nexe/lib/target.js
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/nexe/lib/target.js')
-rw-r--r--node_modules/nexe/lib/target.js81
1 files changed, 81 insertions, 0 deletions
diff --git a/node_modules/nexe/lib/target.js b/node_modules/nexe/lib/target.js
new file mode 100644
index 0000000..1edd863
--- /dev/null
+++ b/node_modules/nexe/lib/target.js
@@ -0,0 +1,81 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+const platforms = ['windows', 'mac', 'alpine', 'linux'], architectures = ['x86', 'x64', 'arm', 'arm64'];
+exports.platforms = platforms;
+exports.architectures = architectures;
+const prettyPlatform = {
+ win32: 'windows',
+ windows: 'windows',
+ win: 'windows',
+ darwin: 'mac',
+ macos: 'mac',
+ mac: 'mac',
+ linux: 'linux',
+ static: 'alpine',
+ alpine: 'alpine',
+};
+const prettyArch = {
+ x86: 'x86',
+ arm6: 'arm',
+ arm64: 'arm64',
+ arm6l: 'arm',
+ arm: 'arm',
+ arm7: 'arm',
+ arm7l: 'arm',
+ amd64: 'x64',
+ ia32: 'x86',
+ x32: 'x86',
+ x64: 'x64',
+};
+function isVersion(x) {
+ if (!x) {
+ return false;
+ }
+ return /^[\d]+$/.test(x.replace(/v|\.|\s+/g, ''));
+}
+function isPlatform(x) {
+ return x in prettyPlatform;
+}
+function isArch(x) {
+ return x in prettyArch;
+}
+class Target {
+ constructor(arch, platform, version) {
+ this.arch = arch;
+ this.platform = platform;
+ this.version = version;
+ }
+ toJSON() {
+ return this.toString();
+ }
+ toString() {
+ return `${this.platform}-${this.arch}-${this.version}`;
+ }
+}
+function targetsEqual(a, b) {
+ return a.arch === b.arch && a.platform === b.platform && a.version === b.version;
+}
+exports.targetsEqual = targetsEqual;
+function getTarget(target = '') {
+ const currentArch = process.arch;
+ let arch = currentArch in prettyArch ? prettyArch[process.arch] : process.arch, platform = prettyPlatform[process.platform], version = process.version.slice(1);
+ if (typeof target !== 'string') {
+ target = `${target.platform}-${target.arch}-${target.version}`;
+ }
+ target
+ .toLowerCase()
+ .split('-')
+ .forEach((x) => {
+ if (isVersion(x)) {
+ version = x.replace(/v/g, '');
+ }
+ if (isPlatform(x)) {
+ platform = prettyPlatform[x];
+ }
+ if (isArch(x)) {
+ arch = prettyArch[x];
+ }
+ });
+ return new Target(arch, platform, version);
+}
+exports.getTarget = getTarget;