import { spawnSync } from "node:child_process"; import path from "node:path"; import { fileURLToPath } from "node:url"; import { resolveHutchCommand } from "./resolve-hutch-command.mjs"; const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), ".."); const [, , subcommand, ...rest] = process.argv; if (!subcommand) { console.error("usage: run-hutch-electrobun.mjs [...args]"); process.exit(1); } const ensureHutch = spawnSync( "bun", [path.join(rootDir, "scripts/ensure-hutch.mjs")], { cwd: rootDir, stdio: "inherit", env: process.env }, ); if (ensureHutch.status !== 0) { process.exit(ensureHutch.status ?? 1); } const hutchCommand = resolveHutchCommand(); const result = spawnSync( hutchCommand, ["electrobun", subcommand, ...rest], { cwd: rootDir, stdio: "inherit", env: process.env, }, ); process.exit(result.status ?? 1);