From 2fca5b213c86a659d0c86967cf5130c40145d2d5 Mon Sep 17 00:00:00 2001 From: Ryan Zimmerman <17342435+RyanZim@users.noreply.github.com> Date: Fri, 2 Apr 2021 07:52:47 -0400 Subject: [PATCH] BREAKING: copy*(): Error when unknown file type is encountered (#880) Replaces & closes #812 --- lib/copy-sync/copy-sync.js | 3 +++ lib/copy/copy.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/copy-sync/copy-sync.js b/lib/copy-sync/copy-sync.js index d837780c3..2d9523ecc 100644 --- a/lib/copy-sync/copy-sync.js +++ b/lib/copy-sync/copy-sync.js @@ -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) { diff --git a/lib/copy/copy.js b/lib/copy/copy.js index 14aab7d5c..c12578db9 100644 --- a/lib/copy/copy.js +++ b/lib/copy/copy.js @@ -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}`)) }) }