From 9a553daf7cba4c343ad4558b9b3d6076db0a613c Mon Sep 17 00:00:00 2001 From: Tetsuharu Ohzeki Date: Thu, 20 Apr 2023 15:28:18 +0900 Subject: [PATCH] fs: add support for mode flag to specify the copy behavior `fs.copyFile()` supports copy-on-write operation if the underlying platform supports it by passing a mode flag. This behavior was added in https://github.com/nodejs/node/commit/a16d88d9e9a6581e463082549823189aba25ca76. This patch adds `mode` flag to `fs.cp()`, `fs.cpSync()`, and `fsPromises.cp()` to allow to change their behaviors to copy files. This test case is based on the test case that was introduced when we add `fs.constants.COPYFILE_FICLONE`. https://github.com/nodejs/node/commit/a16d88d9e9a6581e463082549823189aba25ca76. This test strategy is: - If the platform supports copy-on-write operation, check whether the destination is expected - Otherwise, the operation will fail and check whether the failure error information is expected. Fixes: https://github.com/nodejs/node/issues/47080 PR-URL: https://github.com/nodejs/node/pull/47084 Reviewed-By: Antoine du Hamel --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index fe592ffdac3951..ab6bcf3d3716c7 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -5158,7 +5158,7 @@ changes: pr-url: https://github.com/nodejs/node/pull/47084 description: Accept an additional `mode` option to specify the copy behavior as the `mode` argument of `fs.copyFile()`. - - version: v17.6.0 + - version: v17.6.0 pr-url: https://github.com/nodejs/node/pull/41819 description: Accepts an additional `verbatimSymlinks` option to specify whether to perform path resolution for symlinks.