mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
Add runtime selection feature between Bun and Node.js
This commit is contained in:
31
apps/cli/src/prompts/runtime.ts
Normal file
31
apps/cli/src/prompts/runtime.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user