Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(cli): rephrase not empty directory error message #778

Merged
merged 1 commit into from
May 26, 2021
Merged
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
9 changes: 6 additions & 3 deletions packages/create-nuxt-app/lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,15 @@ cli
if (cliOptions.info) {
return showEnvInfo()
}
const files = fs.existsSync(outDir) ? fs.readdirSync(outDir) : []
console.log()
console.log(chalk`{cyan create-nuxt-app v${version}}`)
if (files.length) {
return console.log(chalk.red(`Can't create ${outDir} because there's already a non-empty directory ${outDir} existing in path.`))

if (fs.existsSync(outDir) && fs.readdirSync(outDir).length) {
const baseDir = outDir === '.' ? path.basename(process.cwd()) : outDir
return console.error(chalk.red(
`Could not create project in ${chalk.bold(baseDir)} because the directory is not empty.`))
}

console.log(chalk`✨ Generating Nuxt.js project in {cyan ${outDir}}`)

const { verbose, answers } = cliOptions
Expand Down