spine-rigc 0.4.0 → 0.6.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.
package/bin/rigc.cjs ADDED
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ /**
5
+ * rigc's `bin` entry has one job: hand off to Bun.
6
+ *
7
+ * npm's `bin` field has to be something any installed Node can run, but rigc
8
+ * itself is a Bun script (top-level await, Bun's own APIs) — its own shebang
9
+ * says so. On a machine without Bun that used to fail as a bare
10
+ * `env: bun: No such file or directory`, with no hint why. This file exists
11
+ * so that failure explains itself: if `bun` is on PATH, run the real CLI
12
+ * (cli.ts, next to this file) under it and disappear — argv, stdio, the exit
13
+ * code and signals all pass straight through. If it isn't, say so once and
14
+ * stop. No downloads, no network, no writes — just the hand-off or the
15
+ * message.
16
+ */
17
+
18
+ const path = require('node:path');
19
+ const { spawnSync } = require('node:child_process');
20
+
21
+ const cli = path.join(__dirname, '..', 'cli.ts');
22
+ const result = spawnSync('bun', [cli, ...process.argv.slice(2)], { stdio: 'inherit' });
23
+
24
+ if (result.error) {
25
+ if (result.error.code === 'ENOENT') {
26
+ process.stderr.write('rigc runs on Bun, which was not found on PATH — install it from https://bun.sh\n');
27
+ } else {
28
+ process.stderr.write(`rigc: could not launch bun: ${result.error.message}\n`);
29
+ }
30
+ process.exit(1);
31
+ }
32
+
33
+ if (result.signal) {
34
+ // A signal (e.g. Ctrl-C) killed the child — die the same way instead of
35
+ // inventing an exit code, so the caller sees the same thing it would have
36
+ // seen running bun directly.
37
+ process.kill(process.pid, result.signal);
38
+ } else {
39
+ process.exit(typeof result.status === 'number' ? result.status : 1);
40
+ }