Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bee76a0

Browse files
committed
fix: fix --force feature when targetDir doesn't exist yet
1 parent 0478ba0 commit bee76a0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ function canSafelyOverwrite(dir) {
3333
}
3434

3535
function emptyDir(dir) {
36+
if (!fs.existsSync(dir)) {
37+
return
38+
}
39+
3640
postOrderDirectoryTraverse(
3741
dir,
3842
(dir) => fs.rmdirSync(dir),
@@ -237,7 +241,7 @@ async function init() {
237241
const needsCypressCT = needsCypress && !needsVitest
238242
const root = path.join(cwd, targetDir)
239243

240-
if (shouldOverwrite) {
244+
if (fs.existsSync(root) && shouldOverwrite) {
241245
emptyDir(root)
242246
} else if (!fs.existsSync(root)) {
243247
fs.mkdirSync(root)

0 commit comments

Comments
 (0)