From dd46bce36feba58d34a343bc757c5de4b914ab12 Mon Sep 17 00:00:00 2001 From: zhenweijin Date: Thu, 11 Apr 2024 12:07:45 +0800 Subject: [PATCH] fs: keep return type of options.filter in cpsync consistent with doc --- lib/internal/fs/cp/cp-sync.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/fs/cp/cp-sync.js b/lib/internal/fs/cp/cp-sync.js index fe342f2dda19ec..9ec27f60662c92 100644 --- a/lib/internal/fs/cp/cp-sync.js +++ b/lib/internal/fs/cp/cp-sync.js @@ -46,7 +46,6 @@ const { parse, resolve, } = require('path'); -const { isPromise } = require('util/types'); function cpSyncFn(src, dest, opts) { // Warn about using preserveTimestamps on 32-bit node @@ -64,7 +63,7 @@ function cpSyncFn(src, dest, opts) { function checkPathsSync(src, dest, opts) { if (opts.filter) { const shouldCopy = opts.filter(src, dest); - if (isPromise(shouldCopy)) { + if (typeof shouldCopy !== 'boolean') { throw new ERR_INVALID_RETURN_VALUE('boolean', 'filter', shouldCopy); } if (!shouldCopy) return { __proto__: null, skipped: true };