You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use throwIfNoEntry for default isFile and isDirectory #255
Performance of skipping error generation is significant (mini-benchmark present in above issue) and the API is backward compatible.
Since this project doesnt use graceful-fs, this change should be available to make right now. I do somewhat worry about usage of monkeypatched graceful-fs, though, as that seems to fall into a weird grey area of deciding semver.
We use fs, not graceful-fs, and it definitely seems very strange to add an option node doesn't support just in case someone is using graceful-fs to patch the builtin.
edit: maybe i misread. this is something node does support? which node versions support it? what happens differently with the option in a node version that doesn't support it?
My only concern with doing this change is that if a consumer is using a monkeypatched graceful-fs, they may run into issues with this change. Since this package does not specify graceful as a dependency, I dont think it is really a "breaking change", but its worth understanding that it may still break some people using a semi-common patch.
Activity
ljharb commentedon Nov 1, 2021
I'm not sure I understand what you're proposing.
We use
fs, notgraceful-fs, and it definitely seems very strange to add an option node doesn't support just in case someone is using graceful-fs to patch the builtin.edit: maybe i misread. this is something node does support? which node versions support it? what happens differently with the option in a node version that doesn't support it?
markjm commentedon Nov 1, 2021
Sorry I should clarify:
throwIfNoEntry is a node supported option that is much more performant than letting statSync throw and immediately catch it (https://nodejs.org/api/fs.html#fsstatsyncpath-options). For that reason, I believe we should use that option here. The option is a no-op in older versions of node, so long as you just keep the try/catch block the same. I will create a PR to showcase the change.
My only concern with doing this change is that if a consumer is using a monkeypatched graceful-fs, they may run into issues with this change. Since this package does not specify graceful as a dependency, I dont think it is really a "breaking change", but its worth understanding that it may still break some people using a semi-common patch.
ljharb commentedon Nov 1, 2021
It is none of our concern what someone does with graceful-fs; that's not a supported use case since it involves monkeypatching.
A PR would be great.
markjm commentedon Nov 1, 2021
@ljharb I have linked the change here