Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

fix: do not proceed if the target directory exists and is non-empty #570

Merged
merged 1 commit into from
Jul 27, 2020
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
5 changes: 5 additions & 0 deletions packages/create-nuxt-app/lib/cli.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node
const path = require('path')
const fs = require('fs')
const sao = require('sao')
const cac = require('cac')
const chalk = require('chalk')
Expand Down Expand Up @@ -33,8 +34,12 @@ 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.`))
}
console.log(chalk`✨ Generating Nuxt.js project in {cyan ${outDir}}`)

const { verbose, answers } = cliOptions
Expand Down