From 3a7b65041be14950585d582b5181f5ad1189d8e4 Mon Sep 17 00:00:00 2001 From: patak Date: Thu, 25 Jan 2024 11:16:36 +0100 Subject: [PATCH] fix: windows add/delete file --- packages/vite/src/node/fsUtils.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/fsUtils.ts b/packages/vite/src/node/fsUtils.ts index ec9c6431bfa645..648b877e612e91 100644 --- a/packages/vite/src/node/fsUtils.ts +++ b/packages/vite/src/node/fsUtils.ts @@ -219,24 +219,28 @@ export function createCachedFsUtils(config: ResolvedConfig): FsUtils { file: string, type: 'directory_maybe_symlink' | 'file_maybe_symlink', ) { - const direntCache = getDirentCacheFromPath(path.dirname(file)) + const direntCache = getDirentCacheFromPath( + normalizePath(path.dirname(file)), + ) if ( direntCache && direntCache.type === 'directory' && direntCache.dirents ) { - direntCache.dirents.set(path.basename(file), { type }) + direntCache.dirents.set(normalizePath(path.basename(file)), { type }) } } function onPathUnlink(file: string) { - const direntCache = getDirentCacheFromPath(path.dirname(file)) + const direntCache = getDirentCacheFromPath( + normalizePath(path.dirname(file)), + ) if ( direntCache && direntCache.type === 'directory' && direntCache.dirents ) { - direntCache.dirents.delete(path.basename(file)) + direntCache.dirents.delete(normalizePath(path.basename(file))) } }