Skip to content

Commit d709eb1

Browse files
committed
perf: delete files concurrently instead of 1 by 1
1 parent 465bcda commit d709eb1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/runtime/src/helpers/files.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,8 +480,13 @@ export const movePublicFiles = async ({
480480
}
481481

482482
export const removeMetadataFiles = async (publish: string) => {
483-
for (const HIDDEN_PATH of HIDDEN_PATHS) {
483+
// Limit concurrent file moves to number of cpus or 2 if there is only 1
484+
const limit = pLimit(Math.max(2, cpus().length))
485+
486+
const removePromises = HIDDEN_PATHS.map((HIDDEN_PATH) => {
484487
const pathToDelete = join(publish, HIDDEN_PATH)
485-
await remove(pathToDelete)
486-
}
488+
return limit(() => remove(pathToDelete))
489+
})
490+
491+
await Promise.all(removePromises)
487492
}

0 commit comments

Comments
 (0)