diff --git a/lib/copy/copy-sync.js b/lib/copy/copy-sync.js index 30e95222..8bc60119 100644 --- a/lib/copy/copy-sync.js +++ b/lib/copy/copy-sync.js @@ -146,7 +146,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 53423e0e..bc188fb6 100644 --- a/lib/copy/copy.js +++ b/lib/copy/copy.js @@ -219,7 +219,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)