diff --git a/lib/move.js b/lib/move.js index 8a6ad99..acb9263 100644 --- a/lib/move.js +++ b/lib/move.js @@ -47,7 +47,10 @@ const moveSync = (from, to, options) => { try { fs.renameSync(from, to); } catch (err) { - if (err.code === "EISDIR" && opts.overwrite === true) { + if ( + (err.code === "EISDIR" || err.code === "EPERM") && + opts.overwrite === true + ) { // Looks like the destination path is a directory, // and we have permission for overwriting, so can remove it. remove.sync(to); @@ -104,7 +107,10 @@ const moveAsync = (from, to, options) => { fs.rename(from, to) .then(resolve) .catch(err => { - if (err.code === "EISDIR" && opts.overwrite === true) { + if ( + (err.code === "EISDIR" || err.code === "EPERM") && + opts.overwrite === true + ) { // Looks like the destination path is a directory, // and we have permission for overwriting, so can remove it. remove