gitwm 0.1.0

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.
Files changed (2) hide show
  1. package/bin/wm +59 -0
  2. package/package.json +1 -0
package/bin/wm ADDED
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execFileSync } = require("child_process");
4
+ const { existsSync } = require("fs");
5
+ const { join } = require("path");
6
+
7
+ const PLATFORMS = {
8
+ "darwin arm64": "gitwm-darwin-arm64",
9
+ "darwin x64": "gitwm-darwin-x64",
10
+ "linux arm64": "gitwm-linux-arm64",
11
+ "linux x64": "gitwm-linux-x64",
12
+ "win32 x64": "gitwm-win32-x64",
13
+ };
14
+
15
+ function getBinaryPath() {
16
+ const platformKey = `${process.platform} ${process.arch}`;
17
+ const pkg = PLATFORMS[platformKey];
18
+
19
+ if (!pkg) {
20
+ console.error(`Unsupported platform: ${platformKey}`);
21
+ console.error(`Supported platforms: ${Object.keys(PLATFORMS).join(", ")}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ const binaryName = process.platform === "win32" ? "wm.exe" : "wm";
26
+
27
+ // Try to find the binary in node_modules
28
+ const paths = [
29
+ // When installed as dependency
30
+ join(__dirname, "..", "node_modules", pkg, "bin", binaryName),
31
+ // When installed globally or via npx
32
+ join(__dirname, "..", "..", pkg, "bin", binaryName),
33
+ // Hoisted in monorepo
34
+ join(__dirname, "..", "..", "..", pkg, "bin", binaryName),
35
+ ];
36
+
37
+ for (const p of paths) {
38
+ if (existsSync(p)) {
39
+ return p;
40
+ }
41
+ }
42
+
43
+ console.error(`Could not find wm binary for ${platformKey}`);
44
+ console.error(`Expected package: ${pkg}`);
45
+ console.error(`Searched paths:`);
46
+ paths.forEach((p) => console.error(` - ${p}`));
47
+ process.exit(1);
48
+ }
49
+
50
+ const binary = getBinaryPath();
51
+
52
+ try {
53
+ execFileSync(binary, process.argv.slice(2), { stdio: "inherit" });
54
+ } catch (error) {
55
+ if (error.status !== undefined) {
56
+ process.exit(error.status);
57
+ }
58
+ throw error;
59
+ }
package/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"gitwm","version":"0.1.0","description":"git worktree manager","license":"MIT","bin":{"wm":"bin/wm"},"files":["bin"],"optionalDependencies":{"gitwm-darwin-arm64":"0.1.0","gitwm-darwin-x64":"0.1.0","gitwm-linux-arm64":"0.1.0","gitwm-linux-x64":"0.1.0","gitwm-win32-x64":"0.1.0"}}