@yoqa/runner 0.3.12

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.
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+
4
+ const { spawn } = require("node:child_process");
5
+ const { existsSync } = require("node:fs");
6
+ const { homedir } = require("node:os");
7
+ const { dirname, join } = require("node:path");
8
+
9
+ function findBun() {
10
+ const fromEnv = process.env.BUN_INSTALL ? join(process.env.BUN_INSTALL, "bin", "bun") : null;
11
+ const candidates = [
12
+ fromEnv,
13
+ join(homedir(), ".bun", "bin", "bun"),
14
+ "/opt/homebrew/bin/bun",
15
+ "/usr/local/bin/bun",
16
+ ].filter(Boolean);
17
+ for (const candidate of candidates) {
18
+ if (existsSync(candidate)) return candidate;
19
+ }
20
+ return "bun";
21
+ }
22
+
23
+ const entry = join(dirname(__filename), "..", "dist", "index.js");
24
+ if (!existsSync(entry)) {
25
+ console.error(
26
+ `yoqa-runner: bundled entry not found at ${entry}. Reinstall @yoqa/runner or run the package build.`,
27
+ );
28
+ process.exit(1);
29
+ }
30
+
31
+ const bun = findBun();
32
+ const child = spawn(bun, [entry, ...process.argv.slice(2)], {
33
+ stdio: "inherit",
34
+ env: process.env,
35
+ });
36
+
37
+ child.on("error", (error) => {
38
+ if (error && error.code === "ENOENT") {
39
+ console.error(
40
+ "yoqa-runner needs Bun to start the local runner.\nInstall: https://bun.sh (curl -fsSL https://bun.sh/install | bash)\nOr set YOQA_RUNNER_BIN to a yoqa-runner binary.",
41
+ );
42
+ process.exit(1);
43
+ return;
44
+ }
45
+ console.error(error);
46
+ process.exit(1);
47
+ });
48
+
49
+ child.on("exit", (code, signal) => {
50
+ if (signal) {
51
+ process.kill(process.pid, signal);
52
+ return;
53
+ }
54
+ process.exit(code ?? 1);
55
+ });