Skip to content

Commit

Permalink
fs: fix cp dir/non-dir mismatch error messages
Browse files Browse the repository at this point in the history
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: nodejs#44598 (comment)
  • Loading branch information
fahrradflucht committed May 25, 2024
1 parent 177b8b9 commit d62cf9b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/internal/fs/cp/cp-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function checkPathsSync(src, dest, opts) {
}
if (srcStat.isDirectory() && !destStat.isDirectory()) {
throw new ERR_FS_CP_DIR_TO_NON_DIR({
message: `cannot overwrite directory ${src} ` +
`with non-directory ${dest}`,
message: `cannot overwrite non-directory ${dest} ` +
`with directory ${src}`,
path: dest,
syscall: 'cp',
errno: EISDIR,
Expand All @@ -92,8 +92,8 @@ function checkPathsSync(src, dest, opts) {
}
if (!srcStat.isDirectory() && destStat.isDirectory()) {
throw new ERR_FS_CP_NON_DIR_TO_DIR({
message: `cannot overwrite non-directory ${src} ` +
`with directory ${dest}`,
message: `cannot overwrite directory ${dest} ` +
`with non-directory ${src}`,
path: dest,
syscall: 'cp',
errno: ENOTDIR,
Expand Down
8 changes: 4 additions & 4 deletions lib/internal/fs/cp/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ async function checkPaths(src, dest, opts) {
}
if (srcStat.isDirectory() && !destStat.isDirectory()) {
throw new ERR_FS_CP_DIR_TO_NON_DIR({
message: `cannot overwrite directory ${src} ` +
`with non-directory ${dest}`,
message: `cannot overwrite non-directory ${dest} ` +
`with directory ${src}`,
path: dest,
syscall: 'cp',
errno: EISDIR,
Expand All @@ -96,8 +96,8 @@ async function checkPaths(src, dest, opts) {
}
if (!srcStat.isDirectory() && destStat.isDirectory()) {
throw new ERR_FS_CP_NON_DIR_TO_DIR({
message: `cannot overwrite non-directory ${src} ` +
`with directory ${dest}`,
message: `cannot overwrite directory ${dest} ` +
`with non-directory ${src}`,
path: dest,
syscall: 'cp',
errno: ENOTDIR,
Expand Down

0 comments on commit d62cf9b

Please sign in to comment.