mirror of
https://github.com/pnpm/pnpm.git
synced 2026-01-08 15:08:27 -05:00
perf: optimize fs-hard-link-dir
This commit is contained in:
5
.changeset/gorgeous-hounds-train.md
Normal file
5
.changeset/gorgeous-hounds-train.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/fs.hard-link-dir": patch
|
||||
---
|
||||
|
||||
Performance optimization.
|
||||
@@ -11,17 +11,18 @@ export async function hardLinkDir (src: string, destDirs: string[]) {
|
||||
if (file === 'node_modules') return
|
||||
const srcFile = path.join(src, file)
|
||||
if ((await fs.lstat(srcFile)).isDirectory()) {
|
||||
await Promise.all(
|
||||
const destSubdirs = await Promise.all(
|
||||
destDirs.map(async (destDir) => {
|
||||
const destFile = path.join(destDir, file)
|
||||
const destSubdir = path.join(destDir, file)
|
||||
try {
|
||||
await fs.mkdir(destFile, { recursive: true })
|
||||
await fs.mkdir(destSubdir, { recursive: true })
|
||||
} catch (err: any) { // eslint-disable-line
|
||||
if (err.code !== 'EEXIST') throw err
|
||||
}
|
||||
return hardLinkDir(srcFile, [destFile])
|
||||
return destSubdir
|
||||
})
|
||||
)
|
||||
await hardLinkDir(srcFile, destSubdirs)
|
||||
return
|
||||
}
|
||||
await Promise.all(
|
||||
|
||||
Reference in New Issue
Block a user