feat(cli): add overwrite confirmation for existing components (#66)
This commit is contained in:
parent
05da2d82f3
commit
f2d66d4632
|
|
@ -128,15 +128,28 @@ export const add = new Command()
|
||||||
|
|
||||||
if (existingComponent.length && !options.overwrite) {
|
if (existingComponent.length && !options.overwrite) {
|
||||||
if (selectedComponents.includes(item.name)) {
|
if (selectedComponents.includes(item.name)) {
|
||||||
logger.warn(
|
spinner.stop()
|
||||||
`Component ${item.name} already exists. Use ${chalk.green(
|
const { overwrite } = await prompts({
|
||||||
'--overwrite',
|
type: 'confirm',
|
||||||
)} to overwrite.`,
|
name: 'overwrite',
|
||||||
)
|
message: `Component ${item.name} already exists. Would you like to overwrite?`,
|
||||||
process.exit(1)
|
initial: false,
|
||||||
}
|
})
|
||||||
|
|
||||||
continue
|
if (!overwrite) {
|
||||||
|
logger.info(
|
||||||
|
`Skipped ${item.name}. To overwrite, run with the ${chalk.green(
|
||||||
|
'--overwrite',
|
||||||
|
)} flag.`,
|
||||||
|
)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
spinner.start(`Installing ${item.name}...`)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const file of item.files) {
|
for (const file of item.files) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user