backlog.md 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.js +3 -6
- package/package.json +2 -1
- package/resolveBinary.cjs +33 -0
package/cli.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { spawn } = require("node:child_process");
|
|
4
|
+
const { resolveBinaryPath } = require("./resolveBinary.cjs");
|
|
4
5
|
|
|
5
|
-
// Resolve binary from platform-specific package
|
|
6
|
-
const platform = process.platform;
|
|
7
|
-
const arch = process.arch;
|
|
8
|
-
const packageName = `backlog.md-${platform}-${arch}`;
|
|
9
6
|
let binaryPath;
|
|
10
7
|
try {
|
|
11
|
-
binaryPath =
|
|
8
|
+
binaryPath = resolveBinaryPath();
|
|
12
9
|
} catch {
|
|
13
|
-
console.error(`Binary package not installed for ${platform}-${arch}.`);
|
|
10
|
+
console.error(`Binary package not installed for ${process.platform}-${process.arch}.`);
|
|
14
11
|
process.exit(1);
|
|
15
12
|
}
|
|
16
13
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function mapPlatform(platform = process.platform) {
|
|
2
|
+
switch (platform) {
|
|
3
|
+
case "win32":
|
|
4
|
+
return "windows";
|
|
5
|
+
case "darwin":
|
|
6
|
+
case "linux":
|
|
7
|
+
return platform;
|
|
8
|
+
default:
|
|
9
|
+
return platform;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function mapArch(arch = process.arch) {
|
|
14
|
+
switch (arch) {
|
|
15
|
+
case "x64":
|
|
16
|
+
case "arm64":
|
|
17
|
+
return arch;
|
|
18
|
+
default:
|
|
19
|
+
return arch;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getPackageName(platform = process.platform, arch = process.arch) {
|
|
24
|
+
return `backlog.md-${mapPlatform(platform)}-${mapArch(arch)}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveBinaryPath(platform = process.platform, arch = process.arch) {
|
|
28
|
+
const packageName = getPackageName(platform, arch);
|
|
29
|
+
const binary = `backlog${platform === "win32" ? ".exe" : ""}`;
|
|
30
|
+
return require.resolve(`${packageName}/${binary}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
module.exports = { getPackageName, resolveBinaryPath };
|