diff --git a/.changeset/tidy-cows-poke.md b/.changeset/tidy-cows-poke.md new file mode 100644 index 00000000000..360edb64eb7 --- /dev/null +++ b/.changeset/tidy-cows-poke.md @@ -0,0 +1,5 @@ +--- +"shadcn-ui": minor +--- + +ask for overwrite diff --git a/packages/cli/src/commands/add.ts b/packages/cli/src/commands/add.ts index bd33a94119e..553e430de41 100644 --- a/packages/cli/src/commands/add.ts +++ b/packages/cli/src/commands/add.ts @@ -138,15 +138,27 @@ export const add = new Command() if (existingComponent.length && !options.overwrite) { if (selectedComponents.includes(item.name)) { - logger.warn( - `Component ${item.name} already exists. Use ${chalk.green( - "--overwrite" - )} to overwrite.` - ) - process.exit(1) - } + spinner.stop() + const { overwrite } = await prompts({ + type: "confirm", + name: "overwrite", + message: `Component ${item.name} already exists. Would you like to overwrite?`, + initial: false, + }) + + if (!overwrite) { + logger.info( + `Skipped ${item.name}. To overwrite, run with the ${chalk.green( + "--overwrite" + )} flag.` + ) + continue + } - continue + spinner.start(`Installing ${item.name}...`) + } else { + continue + } } for (const file of item.files) {