fs: fix wrong order of file names in cpSync error message

PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
Nicholas Paun 2025-09-07 11:15:13 -07:00 committed by GitHub
parent ce08561b67
commit f855cda2a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -3270,7 +3270,7 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& 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) {

View File

@ -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/ }
);
}