diff --git a/lib/internal/fs/cp/cp-sync.js b/lib/internal/fs/cp/cp-sync.js index f9d159a193107e..20c77fc7cb1631 100644 --- a/lib/internal/fs/cp/cp-sync.js +++ b/lib/internal/fs/cp/cp-sync.js @@ -158,11 +158,6 @@ function handleFilterAndCopy(destStat, src, dest, opts) { return getStats(destStat, src, dest, opts); } -function startCopy(destStat, src, dest, opts) { - if (opts.filter && !opts.filter(src, dest)) return; - return getStats(destStat, src, dest, opts); -} - function getStats(destStat, src, dest, opts) { const statSyncFn = opts.dereference ? statSync : lstatSync; const srcStat = statSyncFn(src); @@ -284,9 +279,9 @@ function copyDir(src, dest, opts) { const { name } = dirent; const srcItem = join(src, name); const destItem = join(dest, name); + if (opts.filter && !opts.filter(srcItem, destItem)) continue; const { destStat } = checkPathsSync(srcItem, destItem, opts); - - startCopy(destStat, srcItem, destItem, opts); + getStats(destStat, srcItem, destItem, opts); } } finally { dir.closeSync();