Skip to content

Commit 3a7b650

Browse files
committed
fix: windows add/delete file
1 parent 98bc3dc commit 3a7b650

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

packages/vite/src/node/fsUtils.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,24 +219,28 @@ export function createCachedFsUtils(config: ResolvedConfig): FsUtils {
219219
file: string,
220220
type: 'directory_maybe_symlink' | 'file_maybe_symlink',
221221
) {
222-
const direntCache = getDirentCacheFromPath(path.dirname(file))
222+
const direntCache = getDirentCacheFromPath(
223+
normalizePath(path.dirname(file)),
224+
)
223225
if (
224226
direntCache &&
225227
direntCache.type === 'directory' &&
226228
direntCache.dirents
227229
) {
228-
direntCache.dirents.set(path.basename(file), { type })
230+
direntCache.dirents.set(normalizePath(path.basename(file)), { type })
229231
}
230232
}
231233

232234
function onPathUnlink(file: string) {
233-
const direntCache = getDirentCacheFromPath(path.dirname(file))
235+
const direntCache = getDirentCacheFromPath(
236+
normalizePath(path.dirname(file)),
237+
)
234238
if (
235239
direntCache &&
236240
direntCache.type === 'directory' &&
237241
direntCache.dirents
238242
) {
239-
direntCache.dirents.delete(path.basename(file))
243+
direntCache.dirents.delete(normalizePath(path.basename(file)))
240244
}
241245
}
242246

0 commit comments

Comments
 (0)