Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(optimizer): check .vite/deps directory existence before removing #11499

Merged
merged 2 commits into from Jan 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/vite/src/node/utils.ts
Expand Up @@ -606,7 +606,12 @@ export function copyDir(srcDir: string, destDir: string): void {
export const removeDir = isWindows
? promisify(gracefulRemoveDir)
: function removeDirSync(dir: string) {
fs.rmSync(dir, { recursive: true, force: true })
// when removing `.vite/deps`, if it doesn't exist, nodejs may also remove
// other directories within `.vite/`, including `.vite/deps_temp` (bug).
// workaround by checking for directory existence before removing for now.
if (fs.existsSync(dir)) {
bluwy marked this conversation as resolved.
Show resolved Hide resolved
fs.rmSync(dir, { recursive: true, force: true })
}
}
export const renameDir = isWindows ? promisify(gracefulRename) : fs.renameSync

Expand Down