diff --git a/packages/cli/bin/epicenter.mjs b/packages/cli/bin/epicenter.mjs new file mode 100644 index 0000000000..a83ab40fc3 --- /dev/null +++ b/packages/cli/bin/epicenter.mjs @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +import { spawnSync } from "node:child_process"; +import { fileURLToPath } from "node:url"; + +const isBun = typeof Bun !== "undefined"; + +if (!isBun) { + const bunCheck = spawnSync("bun", ["--version"], { stdio: "ignore" }); + + if (bunCheck.status === 0) { + const result = spawnSync( + "bun", + [fileURLToPath(import.meta.url), ...process.argv.slice(2)], + { stdio: "inherit" }, + ); + process.exit(result.status ?? 1); + } + + console.error(`Epicenter CLI requires Bun. + +Install it: + + curl -fsSL https://bun.sh/install | bash + +Then run this command again. Learn more: https://bun.sh`); + process.exit(1); +} + +await import("../src/bin.ts"); diff --git a/packages/cli/package.json b/packages/cli/package.json index d74aecdd18..573649cbb3 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -21,7 +21,7 @@ "main": "./src/index.ts", "types": "./src/index.ts", "bin": { - "epicenter": "./src/bin.ts" + "epicenter": "./bin/epicenter.mjs" }, "dependencies": { "@epicenter/workspace": "workspace:*",