Skip to content

Commit

Permalink
perf(copy): run filter in parallel as well
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Dec 1, 2023
1 parent 46b1ac3 commit 763fc95
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/copy/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,16 @@ async function onDir (srcStat, destStat, src, dest, opts) {
const srcItem = path.join(src, item.name)
const destItem = path.join(dest, item.name)

// skip the item if it is matches by the filter function
const include = await runFilter(srcItem, destItem, opts)
if (!include) continue

promises.push(
stat.checkPaths(srcItem, destItem, 'copy', opts).then(({ destStat }) => {
// If the item is a copyable file, `getStatsAndPerformCopy` will copy it
// If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
runFilter(srcItem, destItem, opts).then(include => {
if (include) {
// only copy the item if it matches the filter function
return stat.checkPaths(srcItem, destItem, 'copy', opts).then(({ destStat }) => {
// If the item is a copyable file, `getStatsAndPerformCopy` will copy it
// If the item is a directory, `getStatsAndPerformCopy` will call `onDir` recursively
return getStatsAndPerformCopy(destStat, srcItem, destItem, opts)
})
}
})
)
}
Expand Down

0 comments on commit 763fc95

Please sign in to comment.