Skip to content

Commit

Permalink
chore: simplify generate code (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
xtx1130 authored and mcollina committed Jul 20, 2019
1 parent 1526078 commit 1a11528
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions generate.js
Expand Up @@ -76,20 +76,19 @@ function generate (dir, cb) {

function cli (args) {
const opts = argv(args)
const dir = opts._[0]

if (opts._[0] && existsSync(opts._[0])) {
if (opts._[0] !== '.' && opts._[0] !== './') {
if (dir && existsSync(dir)) {
if (dir !== '.' && dir !== './') {
log('error', 'directory ' + opts._[0] + ' already exists')
process.exit(1)
}
}
if (opts._[0] === undefined) {
if (dir === undefined) {
log('error', 'must specify a directory to \'fastify generate\'')
process.exit(1)
}

const dir = opts._[0]

if (existsSync(path.join(dir, 'package.json'))) {
log('error', 'a package.json file already exists in target directory')
process.exit(1)
Expand Down

0 comments on commit 1a11528

Please sign in to comment.