Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ const processQuestion = async (question) => {
let answer;
const { type, name, message, default: defaultVal, choices, validate, filter } = question;

const displayMessage = `${message}${defaultVal !== undefined ? ` (default: ${type === "confirm" ? (defaultVal ? "Yes" : "No") : defaultVal})` : ""} `;
const displayMessage = `${message}${defaultVal !== undefined ? ` (default: ${type === "confirm" ? (defaultVal === true ? "Yes" : "No") : defaultVal})` : ""} `;

const confirmHint = defaultVal ? "(Y/n)" : "(y/N)";
const confirmHint = defaultVal === true ? "(Y/n)" : "(y/N)";
if (type === "confirm") {
while (true) {
const input = await ask(
`${chalk.green("?")} ${chalk.bold(message)} ${chalk.dim(confirmHint)} `,
`${chalk.green("?")} ${chalk.bold(displayMessage)} ${chalk.dim(confirmHint)} `,
Comment on lines +24 to +30
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Avoid duplicate (default: ...) text in confirm prompts.

Line [24] appends (default: ...), and Line [30] now renders displayMessage. In src/create-next-quick.js Line [240]-[243], the message already contains (default: Yes), so this can render duplicate suffixes.

💡 Proposed fix
-  const displayMessage = `${message}${defaultVal !== undefined ? ` (default: ${type === "confirm" ? (defaultVal === true ? "Yes" : "No") : defaultVal})` : ""} `;
+  const hasDefaultSuffix = /\(default:\s*[^)]+\)/i.test(message);
+  const displayMessage = `${message}${
+    defaultVal !== undefined && !hasDefaultSuffix
+      ? ` (default: ${type === "confirm" ? (defaultVal === true ? "Yes" : "No") : defaultVal})`
+      : ""
+  } `;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const displayMessage = `${message}${defaultVal !== undefined ? ` (default: ${type === "confirm" ? (defaultVal === true ? "Yes" : "No") : defaultVal})` : ""} `;
const confirmHint = defaultVal ? "(Y/n)" : "(y/N)";
const confirmHint = defaultVal === true ? "(Y/n)" : "(y/N)";
if (type === "confirm") {
while (true) {
const input = await ask(
`${chalk.green("?")} ${chalk.bold(message)} ${chalk.dim(confirmHint)} `,
`${chalk.green("?")} ${chalk.bold(displayMessage)} ${chalk.dim(confirmHint)} `,
const hasDefaultSuffix = /\(default:\s*[^)]+\)/i.test(message);
const displayMessage = `${message}${
defaultVal !== undefined && !hasDefaultSuffix
? ` (default: ${type === "confirm" ? (defaultVal === true ? "Yes" : "No") : defaultVal})`
: ""
} `;
const confirmHint = defaultVal === true ? "(Y/n)" : "(y/N)";
if (type === "confirm") {
while (true) {
const input = await ask(
`${chalk.green("?")} ${chalk.bold(displayMessage)} ${chalk.dim(confirmHint)} `,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/prompts.js` around lines 24 - 30, displayMessage currently always
appends a "(default: ...)" suffix which causes duplicate default text for
confirm prompts because confirmHint and the original message may already include
it; update the displayMessage construction to only add the "(default: ...)"
suffix when defaultVal is defined AND type !== "confirm" (or when the message
does not already contain "(default:"), so in the code that builds displayMessage
change the condition to skip adding the default for confirm prompts (referencing
displayMessage, confirmHint, ask and the type === "confirm" branch).

);
const trimmed = input.trim().toLowerCase();
if (trimmed === "") {
Expand Down Expand Up @@ -201,4 +201,4 @@ const close = () => {
export default {
prompt,
close,
};
};
Loading