relayfile 0.7.21 → 0.7.23

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.
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "relayfile",
3
- "version": "0.7.21",
3
+ "version": "0.7.23",
4
4
  "description": "CLI for relayfile — real-time filesystem for humans and agents",
5
5
  "bin": {
6
6
  "relayfile": "scripts/run.js"
package/scripts/run.js CHANGED
@@ -44,19 +44,46 @@ const candidates = [
44
44
 
45
45
  const binPath = candidates.find((candidate) => fs.existsSync(candidate));
46
46
 
47
- if (!binPath) {
48
- console.error(
49
- `relayfile binary not found for ${os.platform()} ${os.arch()}. Reinstall the package or run postinstall again.`
50
- );
51
- process.exit(1);
47
+ // In a source checkout, postinstall intentionally skips building the
48
+ // binary. Rather than leaving the installed `relayfile` command unusable,
49
+ // fall back to running it straight from Go source.
50
+ function sourceCheckoutRoot() {
51
+ const repoRoot = path.resolve(__dirname, "..", "..", "..");
52
+ if (
53
+ fs.existsSync(path.join(repoRoot, "go.mod")) &&
54
+ fs.existsSync(path.join(repoRoot, "cmd", "relayfile-cli"))
55
+ ) {
56
+ return repoRoot;
57
+ }
58
+ return null;
52
59
  }
53
60
 
54
- const result = spawnSync(binPath, args, {
55
- stdio: "inherit",
56
- });
61
+ let result;
62
+ if (binPath) {
63
+ result = spawnSync(binPath, args, { stdio: "inherit" });
64
+ } else {
65
+ const repoRoot = sourceCheckoutRoot();
66
+ if (!repoRoot) {
67
+ console.error(
68
+ `relayfile binary not found for ${os.platform()} ${os.arch()}. Reinstall the package or run postinstall again.`
69
+ );
70
+ process.exit(1);
71
+ }
72
+ result = spawnSync("go", ["run", "./cmd/relayfile-cli", ...args], {
73
+ cwd: repoRoot,
74
+ stdio: "inherit",
75
+ });
76
+ if (result.error && result.error.code === "ENOENT") {
77
+ console.error(
78
+ "relayfile binary not found and Go is not installed to run from source. " +
79
+ "Install Go or run `npm run build --workspace=packages/cli`."
80
+ );
81
+ process.exit(1);
82
+ }
83
+ }
57
84
 
58
85
  if (result.error) {
59
- console.error(`Failed to launch relayfile binary: ${result.error.message}`);
86
+ console.error(`Failed to launch relayfile: ${result.error.message}`);
60
87
  process.exit(1);
61
88
  }
62
89
 
@@ -64,4 +91,13 @@ if (typeof result.status === "number") {
64
91
  process.exit(result.status);
65
92
  }
66
93
 
94
+ // The child was terminated by a signal: spawnSync reports status === null
95
+ // and signal === <name>. Preserve conventional 128 + signal-number exit
96
+ // semantics (e.g. 130 for SIGINT) so callers can distinguish user
97
+ // cancellation from a generic failure.
98
+ if (result.signal) {
99
+ const signum = os.constants.signals[result.signal];
100
+ process.exit(typeof signum === "number" ? 128 + signum : 1);
101
+ }
102
+
67
103
  process.exit(1);