diff --git a/lib/copy/copy-sync.js b/lib/copy/copy-sync.js index 551abe0c..e2801eed 100644 --- a/lib/copy/copy-sync.js +++ b/lib/copy/copy-sync.js @@ -154,7 +154,7 @@ function onLink (destStat, src, dest, opts) { // prevent copy if src is a subdir of dest since unlinking // dest in this case would result in removing src contents // and therefore a broken symlink would be created. - if (fs.statSync(dest).isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) { + if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`) } return copyLink(resolvedSrc, dest) diff --git a/lib/copy/copy.js b/lib/copy/copy.js index 09d53dfd..9e2e62e7 100644 --- a/lib/copy/copy.js +++ b/lib/copy/copy.js @@ -216,7 +216,7 @@ function onLink (destStat, src, dest, opts, cb) { // do not copy if src is a subdir of dest since unlinking // dest in this case would result in removing src contents // and therefore a broken symlink would be created. - if (destStat.isDirectory() && stat.isSrcSubdir(resolvedDest, resolvedSrc)) { + if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) { return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`)) } return copyLink(resolvedSrc, dest, cb)