mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
32 lines
692 B
TypeScript
32 lines
692 B
TypeScript
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;
|
|
}
|