-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Fully decorated fs.promises for complete fs replacement? #28545
Comments
I ran into the same problem. I personally think it would be best to just add another set of properties to the main part with |
adding promise to the name would be rather annoying for continued usage though. +1 to adding the constants and such to the promises object. |
To take this a bit further, I forgot to include Here's the full list of what's in
What I want to be able to do is just Regarding problems with ESM, can you elaborate? Does having a |
I probably sound insane, but I'd also like to see sync methods exported on |
In hindsight, I'm very unhappy with |
That was discussed a lot at the time and decided pretty overwhelmingly that the breakage just wasn't worth it. Not all these functions are easily switchable on last argument presence (exists being the best example). But regardless, this issue isn't a question about large scale redesigns, that's not going to get anywhere in any meaningful amount of time. I just want a well decorated fs.promises for now. Perhaps something more radical can be exported for ESM or under a namespace. That's not this issue though. |
There's been no activity on this for nearly a year. Many of the functions on |
I've got into the habit of
const fs = require('fs').promises
, which is fine for the most part for niceasync
/await
code. But since it's not decorated with thefs
properties other than promisified versions of the core functions that usefulness breaks down.The main one is
fs.constants
, the other ones don't tend to be used directly but there is a case to be made for exposing them too.With the current interface I can't do this kind of thing, which would implement an
await touch(file)
:I can achieve this if I manually decorate it with
fs.constants = require('fs').constants
. So it's not super terrible, just inconvenient and means thatrequire('fs').promises
isn't a fully viablerequire('fs')
replacement forasync
functions.Has this come up? Have we come up with a consistent philosophy for
fs.promises
that would preclude this? Or should I (or someone else) cook up a PR to make this work with the morefs
decorations?constants
at least.Current decorations excluding the standard functions and
promises
are:fs.Dirent
fs.Stats
fs.ReadStream
fs.WriteStream
fs.FileReadStream
fs.FileWriteStream
fs._toUnixTimestamp
(could be excluded)fs.F_OK
(could be excluded, I guess these 4 are here for historical reasons)fs.R_OK
fs.W_OK
fs.X_OK
fs.constants
The text was updated successfully, but these errors were encountered: