| | #!/usr/bin/env node |
| | |
| | |
| | |
| | |
| | |
| | import { spawn } from "child_process"; |
| | import { existsSync } from "fs"; |
| | import { join, dirname } from "path"; |
| | import { fileURLToPath } from "url"; |
| |
|
| | const __dirname = dirname(fileURLToPath(import.meta.url)); |
| | const projectRoot = join(__dirname, ".."); |
| | const isWindows = process.platform === "win32"; |
| | const bunExe = isWindows ? "bun.exe" : "bun"; |
| |
|
| | |
| | const bunPaths = [ |
| | join(projectRoot, "node_modules", ".bin", bunExe), |
| | |
| | "bun", |
| | ]; |
| |
|
| | let bunPath = null; |
| | for (const p of bunPaths) { |
| | if (p === "bun" || existsSync(p)) { |
| | bunPath = p; |
| | break; |
| | } |
| | } |
| |
|
| | if (!bunPath) { |
| | console.error("Could not find bun binary"); |
| | process.exit(1); |
| | } |
| |
|
| | |
| | const args = process.argv.slice(2); |
| | const child = spawn(bunPath, args, { |
| | stdio: "inherit", |
| | shell: isWindows, |
| | }); |
| |
|
| | child.on("exit", (code) => { |
| | process.exit(code ?? 0); |
| | }); |
| |
|
| | child.on("error", (err) => { |
| | console.error("Failed to run bun:", err.message); |
| | process.exit(1); |
| | }); |
| |
|