-
Notifications
You must be signed in to change notification settings - Fork 779
Error when unknown file type is encountered #812
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial concept looks OK; thought I'm not a real expert here; will get @manidlou's second opinion.
Should be mirrored for copySync
, though:
node-fs-extra/lib/copy-sync/copy-sync.js
Line 49 in 7b12b05
else if (srcStat.isSymbolicLink()) return onLink(destStat, src, dest, opts) |
Is this technically |
fs.copy was silently exiting when a socket was encountered in my directory. This prevents silent failure so the user can deal with using fs.copy appropriately.
Updated
I think it could be argued both ways. On one hand semver is about having a public api. In this instance this code broke the conventional contract that callbacks are always called, so it's correcting undefined behavior. On the other hand it really depends on what users of the library are expecting. I got here via stepping through The other major users are https://github.com/webpack-contrib/eslint-loader https://github.com/GoogleChrome/workbox and https://github.com/danethurber/webpack-manifest-plugin. So maybe @ricardogobbosouza @jeffposnick and @DanielRuf? |
I think you mentioned me by accident. I was only a normal contributor for a small CI related PR, nothing more: shellscape/webpack-manifest-plugin@b55ac5d |
Besides this, turning a silent error (warning or notice in other frameworks and languages) to an actual (fatal) error is a breaking change as an error breaks the program flow. |
Ah my bad, I just mentioned the last author on master :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM; but would like @manidlou to review before merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good but I am wondering if that'd be better to throw a more descriptive error by checking all the remaining file types (socket and FIFO pipe) that fs.Stats
object returns. I mean something like this:
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}`))
fs.copy was silently exiting when a socket was encountered in my
directory. This prevents silent failure so the user can deal with using
fs.copy appropriately.