From d839c997e905e475acfac267dddc3d2a8877d0bc Mon Sep 17 00:00:00 2001 From: Nicholas Paun Date: Fri, 5 Sep 2025 11:03:05 -0700 Subject: [PATCH] fs: fix wrong order of file names in cpSync error message --- src/node_file.cc | 2 +- .../parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_file.cc b/src/node_file.cc index 4443f4be8697f8..6772fea0e1db30 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -3270,7 +3270,7 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo& args) { std::string message = "Cannot overwrite non-directory %s with directory %s"; return THROW_ERR_FS_CP_DIR_TO_NON_DIR( - env, message.c_str(), src_path_str, dest_path_str); + env, message.c_str(), dest_path_str, src_path_str); } if (!src_is_dir && dest_is_dir) { diff --git a/test/parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs b/test/parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs index 60438cbe98b8bb..04388f3166b87b 100644 --- a/test/parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs +++ b/test/parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs @@ -14,11 +14,11 @@ if (isInsideDirWithUnusualChars) { tmpdir.refresh(); { - const src = nextdir(); + const src = nextdir('FIRST_DIRECTORY'); mkdirSync(src, mustNotMutateObjectDeep({ recursive: true })); const dest = fixtures.path('copy/kitchen-sink/README.md'); assert.throws( () => cpSync(src, dest), - { code: 'ERR_FS_CP_DIR_TO_NON_DIR' } + { code: 'ERR_FS_CP_DIR_TO_NON_DIR', message: /non-directory .*README\.md with directory .*FIRST_DIRECTORY/ } ); }