Skip to content

Commit 8eb0d9d

Browse files
npauntargos
authored andcommitted
fs: fix wrong order of file names in cpSync error message
PR-URL: #59775 Reviewed-By: Dario Piotrowicz <dario.piotrowicz@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ulises Gascón <ulisesgascongonzalez@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 4fd213c commit 8eb0d9d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3276,7 +3276,7 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
32763276
std::string message =
32773277
"Cannot overwrite non-directory %s with directory %s";
32783278
return THROW_ERR_FS_CP_DIR_TO_NON_DIR(
3279-
env, message.c_str(), src_path_str, dest_path_str);
3279+
env, message.c_str(), dest_path_str, src_path_str);
32803280
}
32813281

32823282
if (!src_is_dir && dest_is_dir) {

test/parallel/test-fs-cp-sync-copy-directory-to-file-error.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ if (isInsideDirWithUnusualChars) {
1414
tmpdir.refresh();
1515

1616
{
17-
const src = nextdir();
17+
const src = nextdir('FIRST_DIRECTORY');
1818
mkdirSync(src, mustNotMutateObjectDeep({ recursive: true }));
1919
const dest = fixtures.path('copy/kitchen-sink/README.md');
2020
assert.throws(
2121
() => cpSync(src, dest),
22-
{ code: 'ERR_FS_CP_DIR_TO_NON_DIR' }
22+
{ code: 'ERR_FS_CP_DIR_TO_NON_DIR', message: /non-directory .*README\.md with directory .*FIRST_DIRECTORY/ }
2323
);
2424
}

0 commit comments

Comments
 (0)