feat(cli): add overwrite confirmation for existing components (#66)
This commit is contained in:
parent
05da2d82f3
commit
f2d66d4632
|
|
@ -128,16 +128,29 @@ 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(
|
||||
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',
|
||||
)} to overwrite.`,
|
||||
)} flag.`,
|
||||
)
|
||||
process.exit(1)
|
||||
continue
|
||||
}
|
||||
|
||||
spinner.start(`Installing ${item.name}...`)
|
||||
}
|
||||
else {
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
for (const file of item.files) {
|
||||
const componentDir = path.resolve(targetDir, item.name)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user