@d-dev/bin-upload-win-x64 0.0.9 → 0.0.11

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/index.js CHANGED
@@ -1,11 +1,46 @@
1
+ #!/usr/bin/env node
1
2
 
2
- import { join } from "node:path";
3
- import { existsSync } from "node:fs";
3
+ import { spawn } from "node:child_process";
4
+ import { chmod } from "node:fs/promises";
4
5
 
5
- export function getBinPath() {
6
- const binPath = join(import.meta.dirname, "bin", "bin-upload.exe");
7
- if (!existsSync(binPath)) {
8
- throw new Error(`Binary not found at expected path: ${binPath}`);
9
- }
10
- return binPath;
6
+ const supported_platforms = new Map([
7
+
8
+ ["linux-x64", "@d-dev/bin-upload-linux-x64"],
9
+
10
+ ["linux-arm64", "@d-dev/bin-upload-linux-arm64"],
11
+
12
+ ["win32-x64", "@d-dev/bin-upload-win-x64"],
13
+
14
+ ["darwin-x64", "@d-dev/bin-upload-darwin-x64"],
15
+
16
+ ["darwin-arm64", "@d-dev/bin-upload-darwin-arm64"],
17
+
18
+ ]);
19
+
20
+ async function run() {
21
+ return new Promise(async (resolve) => {
22
+ const os = process.platform;
23
+ const cpu = process.arch;
24
+ const key = `${os}-${cpu}`;
25
+ if (!supported_platforms.has(key)) {
26
+ throw new Error(`Platform ${key} is not supported`);
27
+ }
28
+
29
+ const args = process.argv.slice(2);
30
+ let getBinPath;
31
+ try {
32
+ const d = await import(supported_platforms.get(key));
33
+ getBinPath = d.getBinPath;
34
+ } catch (err) {
35
+ console.error(`Failed to import ${supported_platforms.get(key)}.`);
36
+ console.error(`Please make sure to install the package ${supported_platforms.get(key)} as a dependency.`);
37
+ throw err;
38
+ }
39
+ const binPath = getBinPath();
40
+ await chmod(binPath, 0o774);
41
+ const cp = spawn(binPath, args, { stdio: "inherit" });
42
+ cp.on("close", resolve);
43
+ });
11
44
  }
45
+
46
+ process.exit(await run());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@d-dev/bin-upload-win-x64",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Publish binaries to npm, pypi, and github releases.",
5
5
  "author": "Derek Worthen <worthend.derek@gmail.com>",
6
6
  "license": "MIT",
@@ -24,13 +24,20 @@
24
24
  "package.json",
25
25
  "index.js",
26
26
  "README.md",
27
- "LICENSE",
28
- "bin"
27
+ "LICENSE"
29
28
  ],
30
29
  "os": [
31
30
  "win32"
32
31
  ],
33
32
  "cpu": [
34
33
  "x64"
35
- ]
34
+ ],
35
+ "bin": "index.js",
36
+ "optionalDependencies": {
37
+ "@d-dev/bin-upload-linux-x64": "0.0.11",
38
+ "@d-dev/bin-upload-linux-arm64": "0.0.11",
39
+ "@d-dev/bin-upload-win-x64": "0.0.11",
40
+ "@d-dev/bin-upload-darwin-x64": "0.0.11",
41
+ "@d-dev/bin-upload-darwin-arm64": "0.0.11"
42
+ }
36
43
  }
Binary file