perf(package-store): don't create dep dir twice

This commit is contained in:
Zoltan Kochan
2020-05-21 02:46:38 +03:00
parent 6cbf186769
commit cbc2192f10
2 changed files with 8 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/package-store": minor
---
Don't try to create the dependency directory twice.

View File

@@ -44,14 +44,14 @@ async function tryImportIndexedDir (importFile: ImportFile, newDir: string, file
const alldirs = new Set<string>()
Object.keys(filenames)
.forEach((f) => {
const dir = path.join(newDir, path.dirname(f))
const dir = path.dirname(f)
if (dir === '.') return
alldirs.add(dir)
})
await Promise.all(
Array.from(alldirs)
.sort((d1, d2) => d1.length - d2.length)
.map((dir) => fs.mkdir(dir, { recursive: true }))
.sort((d1, d2) => d1.length - d2.length) // from shortest to longest
.map((dir) => fs.mkdir(path.join(newDir, dir), { recursive: true }))
)
await Promise.all(
Object.entries(filenames)