From fa10461938f9772b1cb5bb9b4027d340514d22ec Mon Sep 17 00:00:00 2001 From: Shubham Pandey Date: Tue, 22 Aug 2023 23:49:46 +0530 Subject: [PATCH 1/2] doc: updating doc for `fs.cp`, `fsPromises.cp` and `fs.cpSync` --- doc/api/fs.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index 114a51c15dc5d6..527bb7f007bb7a 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1003,6 +1003,15 @@ changes: * `filter` {Function} Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it. Can also return a `Promise` that resolves to `true` or `false` **Default:** `undefined`. + + When using the `recursive` option, please note the following caveat: + + If the filter function is configured to skip certain files based on a + condition, and you are performing a recursive copy operation, be aware that + directories that do not match the filter condition will also be skipped. + This is because the filter function is applied to both files and + directories during recursion. + * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean|Promise} @@ -2353,6 +2362,15 @@ changes: * `filter` {Function} Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it. Can also return a `Promise` that resolves to `true` or `false` **Default:** `undefined`. + + When using the `recursive` option, please note the following caveat: + + If the filter function is configured to skip certain files based on a + condition, and you are performing a recursive copy operation, be aware that + directories that do not match the filter condition will also be skipped. + This is because the filter function is applied to both files and + directories during recursion. + * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean|Promise} @@ -5279,6 +5297,15 @@ changes: exists, throw an error. **Default:** `false`. * `filter` {Function} Function to filter copied files/directories. Return `true` to copy the item, `false` to ignore it. **Default:** `undefined` + + When using the `recursive` option, please note the following caveat: + + If the filter function is configured to skip certain files based on a + condition, and you are performing a recursive copy operation, be aware that + directories that do not match the filter condition will also be skipped. + This is because the filter function is applied to both files and + directories during recursion. + * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean} From 7898fe0fc010d52b3aa6b95d300968057b299daa Mon Sep 17 00:00:00 2001 From: Shubham Pandey Date: Wed, 23 Aug 2023 09:43:18 +0530 Subject: [PATCH 2/2] maing the statement simpler --- doc/api/fs.md | 36 ++++++------------------------------ 1 file changed, 6 insertions(+), 30 deletions(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 527bb7f007bb7a..7fc5bbfed7c518 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1001,17 +1001,9 @@ changes: * `errorOnExist` {boolean} when `force` is `false`, and the destination exists, throw an error. **Default:** `false`. * `filter` {Function} Function to filter copied files/directories. Return - `true` to copy the item, `false` to ignore it. Can also return a `Promise` + `true` to copy the item, `false` to ignore it. When ignoring a directory, + all of its contents will be skipped as well. Can also return a `Promise` that resolves to `true` or `false` **Default:** `undefined`. - - When using the `recursive` option, please note the following caveat: - - If the filter function is configured to skip certain files based on a - condition, and you are performing a recursive copy operation, be aware that - directories that do not match the filter condition will also be skipped. - This is because the filter function is applied to both files and - directories during recursion. - * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean|Promise} @@ -2360,17 +2352,9 @@ changes: * `errorOnExist` {boolean} when `force` is `false`, and the destination exists, throw an error. **Default:** `false`. * `filter` {Function} Function to filter copied files/directories. Return - `true` to copy the item, `false` to ignore it. Can also return a `Promise` + `true` to copy the item, `false` to ignore it. When ignoring a directory, + all of its contents will be skipped as well. Can also return a `Promise` that resolves to `true` or `false` **Default:** `undefined`. - - When using the `recursive` option, please note the following caveat: - - If the filter function is configured to skip certain files based on a - condition, and you are performing a recursive copy operation, be aware that - directories that do not match the filter condition will also be skipped. - This is because the filter function is applied to both files and - directories during recursion. - * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean|Promise} @@ -5296,16 +5280,8 @@ changes: * `errorOnExist` {boolean} when `force` is `false`, and the destination exists, throw an error. **Default:** `false`. * `filter` {Function} Function to filter copied files/directories. Return - `true` to copy the item, `false` to ignore it. **Default:** `undefined` - - When using the `recursive` option, please note the following caveat: - - If the filter function is configured to skip certain files based on a - condition, and you are performing a recursive copy operation, be aware that - directories that do not match the filter condition will also be skipped. - This is because the filter function is applied to both files and - directories during recursion. - + `true` to copy the item, `false` to ignore it. When ignoring a directory, + all of its contents will be skipped as well. **Default:** `undefined` * `src` {string} source path to copy. * `dest` {string} destination path to copy to. * Returns: {boolean}