From 8695c2731599c7fa0aeb3e1516edf55a0386ed3f Mon Sep 17 00:00:00 2001 From: Timothy Lau Date: Fri, 8 Mar 2024 17:07:58 +0800 Subject: [PATCH] fix: Fix directory validation logic and error message --- src/node/init/init.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node/init/init.ts b/src/node/init/init.ts index d8d1dd61..1197c7f9 100644 --- a/src/node/init/init.ts +++ b/src/node/init/init.ts @@ -44,6 +44,7 @@ export async function init() { root: () => text({ message: 'Where should VitePress initialize the config?', + defaultValue: './', initialValue: './', validate(value) { const inputRoot = path.resolve(value) @@ -51,7 +52,7 @@ export async function init() { if (!inputRoot.startsWith(currentRoot)) { return 'Please make sure directory is inside' } - if (fs.pathExistsSync(inputRoot)) { + if (inputRoot != currentRoot && fs.pathExistsSync(inputRoot)) { return `${value} already exists` } }