Skip to content

Commit

Permalink
BREAKING: copy*(): Error when unknown file type is encountered (#880)
Browse files Browse the repository at this point in the history
Replaces & closes #812
  • Loading branch information
RyanZim committed Apr 2, 2021
1 parent 4523526 commit 2fca5b2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/copy-sync/copy-sync.js
Expand Up @@ -47,6 +47,9 @@ function getStats (destStat, src, dest, opts) {
srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
throw new Error(`Unknown file: ${src}`)
}

function onFile (srcStat, destStat, src, dest, opts) {
Expand Down
3 changes: 3 additions & 0 deletions lib/copy/copy.js
Expand Up @@ -72,6 +72,9 @@ function getStats (destStat, src, dest, opts, cb) {
srcStat.isCharacterDevice() ||
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb)
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb)
else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`))
else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`))
return cb(new Error(`Unknown file: ${src}`))
})
}

Expand Down

0 comments on commit 2fca5b2

Please sign in to comment.