Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2fca5b2

Browse files
authored
BREAKING: copy*(): Error when unknown file type is encountered (#880)
Replaces & closes #812
1 parent 4523526 commit 2fca5b2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

lib/copy-sync/copy-sync.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function getStats (destStat, src, dest, opts) {
4747
srcStat.isCharacterDevice() ||
4848
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts)
4949
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts)
50+
else if (srcStat.isSocket()) throw new Error(`Cannot copy a socket file: ${src}`)
51+
else if (srcStat.isFIFO()) throw new Error(`Cannot copy a FIFO pipe: ${src}`)
52+
throw new Error(`Unknown file: ${src}`)
5053
}
5154

5255
function onFile (srcStat, destStat, src, dest, opts) {

lib/copy/copy.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ function getStats (destStat, src, dest, opts, cb) {
7272
srcStat.isCharacterDevice() ||
7373
srcStat.isBlockDevice()) return onFile(srcStat, destStat, src, dest, opts, cb)
7474
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts, cb)
75+
else if (srcStat.isSocket()) return cb(new Error(`Cannot copy a socket file: ${src}`))
76+
else if (srcStat.isFIFO()) return cb(new Error(`Cannot copy a FIFO pipe: ${src}`))
77+
return cb(new Error(`Unknown file: ${src}`))
7578
})
7679
}
7780

0 commit comments

Comments
 (0)