Skip to content
This repository was archived by the owner on Dec 17, 2023. It is now read-only.

Commit 6ed094b

Browse files
committed
make sure dir is empty
1 parent ec58475 commit 6ed094b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/utils/questions.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import inquirer from "inquirer";
22
import { getPkgManager, validateNpmName } from "../functions";
33
import path from "path";
4-
import { existsSync } from "fs";
4+
import { existsSync, readdirSync } from "fs";
55

66
export async function promptName() {
77
const { name } = await inquirer.prompt({
@@ -31,7 +31,8 @@ export async function promptLocation() {
3131
if (dir === ".") return true;
3232

3333
const validation = existsSync(dir);
34-
if (!validation) return true;
34+
const isEmpty = readdirSync(dir).length === 0;
35+
if (!validation || isEmpty) return true;
3536
return "That directory already exists.";
3637
},
3738
});

0 commit comments

Comments
 (0)