fix: no permission to delete empty directories (#7406)

close #7405
This commit is contained in:
Xc authored and GitHub committed 2023-12-13 09:54:40 +01:00
1 parent d5a176af77
commit f3cd0a61d4
2 files changed
+12 -1

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
---
"@pnpm/modules-cleaner": patch
"pnpm": patch
---
Installation should not fail if an empty `node_modules` directory cannot be removed [#7405](https://github.com/pnpm/pnpm/issues/7405).
+6 -1
View File
@@ -114,7 +114,12 @@ export async function prune (
})
}))
await Promise.all(Array.from(removedFromScopes).map((scope) => removeIfEmpty(path.join(modulesDir, scope))))
await removeIfEmpty(modulesDir)
try {
await removeIfEmpty(modulesDir)
} catch {
// On some server setups we might not have permission to remove the node_modules directory.
// That's fine, just proceed.
}
}))
const selectedImporterIds = importers.map((importer) => importer.id).sort()