-
Notifications
You must be signed in to change notification settings - Fork 772
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
Add fs.exists
and fs.existsSync
if it doesn't exist.
#145
Comments
I've considered this, but haven't acted because it's my understanding that despite the fact that they're being deprecated, they're still currently included in io.js and the deprecation message hasn't been enabled yet (or was disabled - nodejs/node#257). So I didn't feel any sense of urgency. Do you know if there's any discussion on actually removing the methods? Regardless, I suppose it wouldn't hurt to be ready. Edit: related: #127 |
I do not.
Yap. I figure if it were added then when they do pull the trigger fs-extra would be ready. |
There was a reason why they were deprecated: They mislead developers to rely on them to ensure that a file exists, but they directly lead to a race condition. Hence, it's basically a good thing that they have been deprecated. I'm not sure if Wouldn't it be better to help spread the word on how to correctly deal with situations where you would use |
A doc note would do. I think it's handy and suspect the race condition concern doesn't apply to most devs using the method. |
I think the core Node devs are wrong on this one. No doubt that they're right that it could lead to a race condition if you check if a file exists before opening it. But sometimes you just want to know if a file exists or not. Not because you want to read/write it, but because the mere existence may indicate the completion of some operation. That being said, they're very useful methods and |
@jprichardson What about |
so how's that so far? will it be added? I was working on a solution and this would be quite handy since I'm already using the fs-extra module but also, the deprecated fs.exists from fs. Btw, isPresent would be a good name :) |
@acmello no work has commenced on this yet. It's not because it's difficult; this implementation should be pretty simple. Rather, it's because it's good to let issues like these marinate for the sake of discussion. To bikeshed a bit, what about |
@jprichardson I was actually glad to see that you guys were talking about it. |
@jprichardson, has this not marinated long enough by now? ;-) There are definitely legitimate uses for In case you're unconvinced, I use Those data files and modules are versioned, part of the source code, so they are not going away and back all the time. They're created once before the application runs and are only changed after the application finishes running. Hence, no race conditions. To give another, even simpler example, I saw a guy who's implementing a text editor, and the editor keeps a list of recently opened files. On startup, if a file from the list doesn't exist anymore, it gets removed. It could also have been temporarily hidden (to better cope with removable media, for example). Regardless, there's no race condition there. These are the legitimate things Remember Ken Thompson: "I abhor a system designed for the ‘user’, if that word is a coded pejorative meaning ‘stupid and unsophisticated’." Totally off-topic: @acmello, cheers, my 9th floor buddy! (To others: We work in the same building). |
I completely agree. This is something that I want to do. There are completely legitimate reasons for the existence of files helping to determine application state. I guess I don't understand the major concern as of yet, since Anyways, I'd be willing to accept a PR in accordance with @jdalton's original issue. That is, Please let me know if I'm missing anything or have a misunderstanding. Thanks! |
I agree, I'm glad you think that way. You might want to consider always replace |
I don't understand the reason behind making .exists() depracated, and frankly I don't care. I like using exists() because it is concise. So, please add this function to fs-extra so that I can keep using it. |
Is Node v7 removing it? |
Just a heads up Node v6.8.0 undeprecated |
@jprichardson Should this be removed from the 1.0.0 milestone? |
Done. Given that |
FWIW, we will probably revisit this when we promisify fs-extra. |
My proposal PR: #406 |
Going to close this out; we'd suggest that people use |
Since
fs.exists
andfs.existsSync
are deprecated it would be good to check if they exist and add them if they don't. You could reference https://github.com/sindresorhus/path-exists.The text was updated successfully, but these errors were encountered: