@youdie006/swapdex 0.167.11 → 0.167.13

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/bin/run.js ADDED
@@ -0,0 +1,41 @@
1
+ // Run the prebuilt binary and leave with its exit status.
2
+ //
3
+ // The launcher is the process a terminal, a process manager or an MCP host
4
+ // signals, but the work happens in the binary it starts. A blocking spawn
5
+ // cannot pass a signal on, so killing the launcher left the binary running
6
+ // with init as its parent - `swapdex proxy` still holding its port. The
7
+ // binary is started asynchronously and every terminating signal the launcher
8
+ // receives is forwarded; the launcher exits only when the binary has.
9
+ const { spawn } = require("child_process");
10
+ const { describeExit } = require("./exit.js");
11
+
12
+ const FORWARDED = ["SIGINT", "SIGTERM", "SIGHUP"];
13
+
14
+ function run(bin, args) {
15
+ const child = spawn(bin, args, { stdio: "inherit" });
16
+ const forwarders = FORWARDED.map((signal) => {
17
+ const forward = () => {
18
+ // The binary may already be gone; nothing else to do then.
19
+ try {
20
+ child.kill(signal);
21
+ } catch {}
22
+ };
23
+ process.on(signal, forward);
24
+ return [signal, forward];
25
+ });
26
+ child.on("error", (error) => {
27
+ console.error(
28
+ `swapdex: failed to run the prebuilt binary (${error.message}). ` +
29
+ "Try `cargo install swapdex`."
30
+ );
31
+ process.exit(1);
32
+ });
33
+ child.on("exit", (status, signal) => {
34
+ for (const [name, forward] of forwarders) process.off(name, forward);
35
+ const { code, note } = describeExit({ status, signal });
36
+ if (note) console.error(note);
37
+ process.exit(code);
38
+ });
39
+ }
40
+
41
+ module.exports = { run };
package/bin/swapdex.js CHANGED
@@ -5,8 +5,7 @@
5
5
  // machine (the esbuild / @biomejs distribution pattern), so nothing runs at
6
6
  // install time and there is no allow-scripts prompt.
7
7
 
8
- const { spawnSync } = require("child_process");
9
- const { describeExit } = require("./exit.js");
8
+ const { run } = require("./run.js");
10
9
 
11
10
  // swapdex is a Unix tool (Linux, WSL, macOS) - it manages 0600 credential files.
12
11
  const PKGS = {
@@ -39,14 +38,4 @@ if (!bin) {
39
38
  process.exit(1);
40
39
  }
41
40
 
42
- const result = spawnSync(bin, process.argv.slice(2), { stdio: "inherit" });
43
- if (result.error) {
44
- console.error(
45
- `swapdex: failed to run the prebuilt binary (${result.error.message}). ` +
46
- "Try `cargo install swapdex`."
47
- );
48
- process.exit(1);
49
- }
50
- const { code, note } = describeExit(result);
51
- if (note) console.error(note);
52
- process.exit(code);
41
+ run(bin, process.argv.slice(2));
package/man/swapdex.1 CHANGED
@@ -1,6 +1,6 @@
1
1
  .ie \n(.g .ds Aq \(aq
2
2
  .el .ds Aq '
3
- .TH swapdex 1 "swapdex 0.167.11"
3
+ .TH swapdex 1 "swapdex 0.167.13"
4
4
  .SH NAME
5
5
  swapdex \- Switch Claude Code / Codex / Gemini / Antigravity login accounts, locally and safely.
6
6
  .SH SYNOPSIS
@@ -139,4 +139,4 @@ Print the man page (roff) to stdout
139
139
  swapdex\-help(1)
140
140
  Print this message or the help of the given subcommand(s)
141
141
  .SH VERSION
142
- v0.167.11
142
+ v0.167.13
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@youdie006/swapdex",
3
- "version": "0.167.11",
3
+ "version": "0.167.13",
4
4
  "description": "Switch between multiple Claude Code, Codex, Gemini, and Antigravity login accounts, locally and safely.",
5
5
  "bin": {
6
6
  "swapdex": "bin/swapdex.js"
@@ -8,14 +8,15 @@
8
8
  "files": [
9
9
  "README.md",
10
10
  "bin/swapdex.js",
11
+ "bin/run.js",
11
12
  "bin/exit.js",
12
13
  "man/swapdex.1"
13
14
  ],
14
15
  "optionalDependencies": {
15
- "@youdie006/swapdex-darwin-arm64": "0.167.11",
16
- "@youdie006/swapdex-darwin-x64": "0.167.11",
17
- "@youdie006/swapdex-linux-x64": "0.167.11",
18
- "@youdie006/swapdex-linux-arm64": "0.167.11"
16
+ "@youdie006/swapdex-darwin-arm64": "0.167.13",
17
+ "@youdie006/swapdex-darwin-x64": "0.167.13",
18
+ "@youdie006/swapdex-linux-x64": "0.167.13",
19
+ "@youdie006/swapdex-linux-arm64": "0.167.13"
19
20
  },
20
21
  "keywords": [
21
22
  "cli",