Skip to content

Commit

Permalink
fix: remove cache template if local template exists
Browse files Browse the repository at this point in the history
  • Loading branch information
w2xi committed Aug 1, 2024
1 parent abd10ab commit 9a33dc1
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions bin/migi-create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,26 +119,30 @@ function downloadAndGenerate(answers: AnswerOptions) {

if (options.offline && fse.pathExistsSync(templatePath)) {
generate(templatePath, destination, answers)
} else {
spinner.start()
download(officialTemplate, templatePath, { clone: false })
.then(() => {
console.log()
spinner.succeed('Successful download template!')
generate(templatePath, destination, answers)
})
.catch((err: Error) => {
console.log()
spinner.fail(
'Failed to download repo ' +
officialTemplate +
': ' +
err.message.trim()
)
console.log()
})
.finally(() => {
spinner.stop()
})
return
}
spinner.start()
// remove if local template exists
if (fse.pathExistsSync(templatePath)) {
fse.removeSync(templatePath)
}
download(officialTemplate, templatePath, { clone: false })
.then(() => {
console.log()
spinner.succeed('Successful download template!')
generate(templatePath, destination, answers)
})
.catch((err: Error) => {
console.log()
spinner.fail(
'Failed to download repo ' +
officialTemplate +
': ' +
err.message.trim()
)
console.log()
})
.finally(() => {
spinner.stop()
})
}

0 comments on commit 9a33dc1

Please sign in to comment.