Add runtime selection feature between Bun and Node.js

This commit is contained in:
Aman Varshney
2025-03-26 01:40:39 +05:30
parent 45cd2fc113
commit 88afd53a4d
22 changed files with 10432 additions and 224 deletions

View File

@@ -0,0 +1,31 @@
import { cancel, isCancel, select } from "@clack/prompts";
import pc from "picocolors";
import type { Runtime } from "../types";
export async function getRuntimeChoice(runtime?: Runtime): Promise<Runtime> {
if (runtime !== undefined) return runtime;
const response = await select<Runtime>({
message: "Which runtime would you like to use?",
options: [
{
value: "bun",
label: "Bun",
hint: "Fast all-in-one JavaScript runtime",
},
{
value: "node",
label: "Node.js",
hint: "Traditional Node.js runtime",
},
],
initialValue: "bun",
});
if (isCancel(response)) {
cancel(pc.red("Operation cancelled"));
process.exit(0);
}
return response;
}