Skip to content

Commit f00ee1c

Browse files
fahrradfluchtmarco-ippolito
authored andcommitted
fs: fix cp dir/non-dir mismatch error messages
The error messages for `ERR_FS_CP_DIR_TO_NON_DIR` and `ERR_FS_CP_NON_DIR_TO_DIR` were the inverse of the copy direction actually performed. Refs: #44598 (comment) PR-URL: #53150 Reviewed-By: Antoine du Hamel <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: LiviaMedeiros <[email protected]> Reviewed-By: Feng Yu <[email protected]>
1 parent b081bc7 commit f00ee1c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

lib/internal/errors.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,12 +1209,12 @@ E('ERR_FEATURE_UNAVAILABLE_ON_PLATFORM',
12091209
', which is being used to run Node.js',
12101210
TypeError);
12111211
E('ERR_FS_CP_DIR_TO_NON_DIR',
1212-
'Cannot overwrite directory with non-directory', SystemError);
1212+
'Cannot overwrite non-directory with directory', SystemError);
12131213
E('ERR_FS_CP_EEXIST', 'Target already exists', SystemError);
12141214
E('ERR_FS_CP_EINVAL', 'Invalid src or dest', SystemError);
12151215
E('ERR_FS_CP_FIFO_PIPE', 'Cannot copy a FIFO pipe', SystemError);
12161216
E('ERR_FS_CP_NON_DIR_TO_DIR',
1217-
'Cannot overwrite non-directory with directory', SystemError);
1217+
'Cannot overwrite directory with non-directory', SystemError);
12181218
E('ERR_FS_CP_SOCKET', 'Cannot copy a socket file', SystemError);
12191219
E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY',
12201220
'Cannot overwrite symlink in subdirectory of self', SystemError);

lib/internal/fs/cp/cp-sync.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ function checkPathsSync(src, dest, opts) {
8383
}
8484
if (srcStat.isDirectory() && !destStat.isDirectory()) {
8585
throw new ERR_FS_CP_DIR_TO_NON_DIR({
86-
message: `cannot overwrite directory ${src} ` +
87-
`with non-directory ${dest}`,
86+
message: `cannot overwrite non-directory ${dest} ` +
87+
`with directory ${src}`,
8888
path: dest,
8989
syscall: 'cp',
9090
errno: EISDIR,
@@ -93,8 +93,8 @@ function checkPathsSync(src, dest, opts) {
9393
}
9494
if (!srcStat.isDirectory() && destStat.isDirectory()) {
9595
throw new ERR_FS_CP_NON_DIR_TO_DIR({
96-
message: `cannot overwrite non-directory ${src} ` +
97-
`with directory ${dest}`,
96+
message: `cannot overwrite directory ${dest} ` +
97+
`with non-directory ${src}`,
9898
path: dest,
9999
syscall: 'cp',
100100
errno: ENOTDIR,

lib/internal/fs/cp/cp.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ async function checkPaths(src, dest, opts) {
8686
}
8787
if (srcStat.isDirectory() && !destStat.isDirectory()) {
8888
throw new ERR_FS_CP_DIR_TO_NON_DIR({
89-
message: `cannot overwrite directory ${src} ` +
90-
`with non-directory ${dest}`,
89+
message: `cannot overwrite non-directory ${dest} ` +
90+
`with directory ${src}`,
9191
path: dest,
9292
syscall: 'cp',
9393
errno: EISDIR,
@@ -96,8 +96,8 @@ async function checkPaths(src, dest, opts) {
9696
}
9797
if (!srcStat.isDirectory() && destStat.isDirectory()) {
9898
throw new ERR_FS_CP_NON_DIR_TO_DIR({
99-
message: `cannot overwrite non-directory ${src} ` +
100-
`with directory ${dest}`,
99+
message: `cannot overwrite directory ${dest} ` +
100+
`with non-directory ${src}`,
101101
path: dest,
102102
syscall: 'cp',
103103
errno: ENOTDIR,

0 commit comments

Comments
 (0)