-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.ts
More file actions
26 lines (20 loc) · 890 Bytes
/
cli.ts
File metadata and controls
26 lines (20 loc) · 890 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env node
import { spawnSync } from "node:child_process";
import { fileURLToPath } from "node:url";
import path from "node:path";
const args = process.argv.slice(2);
const bunCmd = process.platform === "win32" ? "bun.exe" : "bun";
const bunCheck = spawnSync(bunCmd, ["--version"], { stdio: "ignore" });
if (bunCheck.error || bunCheck.status !== 0) {
console.error("DAEMON requires Bun. Install it from https://bun.sh and try again.");
process.exit(1);
}
const packageRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
const entry = path.join(packageRoot, "src", "index.tsx");
const result = spawnSync(bunCmd, [entry, ...args], { stdio: "inherit" });
if (result.error) {
const error = result.error instanceof Error ? result.error : new Error(String(result.error));
console.error(error.message);
process.exit(1);
}
process.exit(result.status ?? 0);