diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 5b8009f802e534..8ab4a63a0f7110 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1204,12 +1204,12 @@ E('ERR_FEATURE_UNAVAILABLE_ON_PLATFORM', ', which is being used to run Node.js', TypeError); E('ERR_FS_CP_DIR_TO_NON_DIR', - 'Cannot overwrite directory with non-directory', SystemError); + 'Cannot overwrite non-directory with directory', SystemError); E('ERR_FS_CP_EEXIST', 'Target already exists', SystemError); E('ERR_FS_CP_EINVAL', 'Invalid src or dest', SystemError); E('ERR_FS_CP_FIFO_PIPE', 'Cannot copy a FIFO pipe', SystemError); E('ERR_FS_CP_NON_DIR_TO_DIR', - 'Cannot overwrite non-directory with directory', SystemError); + 'Cannot overwrite directory with non-directory', SystemError); E('ERR_FS_CP_SOCKET', 'Cannot copy a socket file', SystemError); E('ERR_FS_CP_SYMLINK_TO_SUBDIRECTORY', 'Cannot overwrite symlink in subdirectory of self', SystemError); diff --git a/lib/internal/fs/cp/cp-sync.js b/lib/internal/fs/cp/cp-sync.js index 2aaf36aa7df47e..aebc575365dd2e 100644 --- a/lib/internal/fs/cp/cp-sync.js +++ b/lib/internal/fs/cp/cp-sync.js @@ -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, @@ -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, diff --git a/lib/internal/fs/cp/cp.js b/lib/internal/fs/cp/cp.js index 130bf98ae7be4c..f59bbdb1e59e61 100644 --- a/lib/internal/fs/cp/cp.js +++ b/lib/internal/fs/cp/cp.js @@ -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, @@ -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,