UNPKG

@reliverse/rse

Version:

@reliverse/rse is your all-in-one companion for bootstrapping and improving any kind of projects (especially web apps built with frameworks like Next.js) — whether you're kicking off something new or upgrading an existing app. It is also a little AI-power

33 lines (32 loc) 929 B
import { relinka } from "@reliverse/relinka"; import { confirmPrompt } from "@reliverse/rempts"; export async function decide(config, behaviorKey, title, content, defaultValue, skipPrompts) { try { let behavior = config?.[behaviorKey] ?? "prompt"; if (skipPrompts && behavior === "prompt") { behavior = "autoYes"; } switch (behavior) { case "autoYes": relinka("verbose", `Auto-answering YES to: "${title}"`); return true; case "autoNo": relinka("verbose", `Auto-answering NO to: "${title}"`); return false; // default is "prompt": default: return await confirmPrompt({ title, content: content ?? "", defaultValue }); } } catch (error) { relinka( "error", "Failed to get decision:", error instanceof Error ? error.message : String(error) ); return defaultValue; } }