@autumnk/gwt 0.1.2

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 (3) hide show
  1. package/README.md +3 -0
  2. package/bin/gwt.js +54 -0
  3. package/package.json +30 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @autumnk/gwt
2
+
3
+ Native Rust Git worktree switcher. See the [project repository](https://github.com/LMKKK/gwt) for usage and development documentation.
package/bin/gwt.js ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawnSync } = require("node:child_process");
5
+
6
+ function libc() {
7
+ if (process.platform !== "linux") return "";
8
+ if (process.report && typeof process.report.getReport === "function") {
9
+ const report = process.report.getReport();
10
+ if (report.header && report.header.glibcVersionRuntime) return "gnu";
11
+ }
12
+ return "musl";
13
+ }
14
+
15
+ const platform = process.platform;
16
+ const arch = process.arch;
17
+ const suffix = platform === "linux" ? `-${libc()}` : "";
18
+ const packageName = `@autumnk/gwt-${platform}-${arch}${suffix}`;
19
+
20
+ if (!(["darwin", "linux"].includes(platform)) || !(["arm64", "x64"].includes(arch))) {
21
+ console.error(`gwt: unsupported platform: ${platform}-${arch}`);
22
+ process.exit(1);
23
+ }
24
+
25
+ let binary;
26
+ try {
27
+ binary = require.resolve(`${packageName}/bin/gwt`);
28
+ } catch {
29
+ console.error(`gwt: platform package ${packageName} is not installed.`);
30
+ console.error("Try reinstalling @autumnk/gwt without disabling optional dependencies.");
31
+ process.exit(1);
32
+ }
33
+
34
+ if (typeof process.execve === "function") {
35
+ try {
36
+ process.execve(binary, [binary, ...process.argv.slice(2)], process.env);
37
+ } catch (error) {
38
+ console.error(`gwt: failed to exec ${binary}: ${error.message}`);
39
+ process.exit(1);
40
+ }
41
+ }
42
+
43
+ // Node.js before 22.15 does not expose execve, so retain equivalent stdio and
44
+ // signal/exit behavior with a synchronous child process on older installations.
45
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
46
+ if (result.error) {
47
+ console.error(`gwt: failed to start ${binary}: ${result.error.message}`);
48
+ process.exit(1);
49
+ }
50
+ if (result.signal) {
51
+ process.kill(process.pid, result.signal);
52
+ } else {
53
+ process.exit(result.status ?? 1);
54
+ }
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@autumnk/gwt",
3
+ "version": "0.1.2",
4
+ "description": "A fast interactive Git worktree switcher",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/LMKKK/gwt",
9
+ "directory": "packages/gwt"
10
+ },
11
+ "bin": {
12
+ "gwt": "bin/gwt.js"
13
+ },
14
+ "files": ["bin", "README.md"],
15
+ "publishConfig": {
16
+ "access": "public",
17
+ "provenance": true
18
+ },
19
+ "optionalDependencies": {
20
+ "@autumnk/gwt-darwin-arm64": "0.1.2",
21
+ "@autumnk/gwt-darwin-x64": "0.1.2",
22
+ "@autumnk/gwt-linux-arm64-gnu": "0.1.2",
23
+ "@autumnk/gwt-linux-arm64-musl": "0.1.2",
24
+ "@autumnk/gwt-linux-x64-gnu": "0.1.2",
25
+ "@autumnk/gwt-linux-x64-musl": "0.1.2"
26
+ },
27
+ "engines": {
28
+ "node": ">=18"
29
+ }
30
+ }