Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Update fs.markdown to account for correct uses of fs.exists() #7944

Closed
wants to merge 1 commit into from
Closed

Update fs.markdown to account for correct uses of fs.exists() #7944

wants to merge 1 commit into from

Conversation

oconnore
Copy link

fs.exists() is not an anti-pattern in itself. It becomes an anti-pattern when used in a particular way. Checking the existence of a file is quite useful when, for example, checking filesystem based locks or status files (of course, grabbing a lock is the same problem, and should use fs.open() directly), and the documentation shouldn't be so narrow in its assumptions.

`fs.exists()` is not an anti-pattern in itself. It becomes an anti-pattern when used in a particular way. Checking the existence of a file is quite useful when building filesystem based locks, and the documentation shouldn't be so narrow in its assumptions.
@vkurchatkin
Copy link

@oconnore fs.exists is an antipattern because it doesn't follow (error, result) convention. it probably should be deprecated at some point.

@oconnore
Copy link
Author

@vkurchatkin ah, but an api inconsistency is different than what the documentation is saying. In that case, the documentation should describe the inconsistency (lack of err argument in the callback, need to use domains? Or does error = false?), and mention a correct work-around, perhaps using fs.stat()?

@vkurchatkin
Copy link

@oconnore it should, I guess. Actually fs.exists it's nothing more than fs.stat with false result if err is not falsey.

@jasnell jasnell added the doc label Aug 13, 2015
@jasnell
Copy link
Member

jasnell commented Aug 14, 2015

Closing this here. A new PR has been opened in http://github.com/nodejs/node

@jasnell jasnell closed this Aug 14, 2015
jasnell added a commit to jasnell/node that referenced this pull request Aug 26, 2015
per: nodejs/node-v0.x-archive#7944

originally submitted by @oconnore

Minor update to the description in `fs.exists()`
jasnell added a commit to nodejs/node that referenced this pull request Aug 26, 2015
per: nodejs/node-v0.x-archive#7944

originally submitted by @oconnore

Minor update to the description in `fs.exists()`

Reviewed By: Sakthipriyan Vairamani <[email protected]>
PR-URL: #2378
jasnell added a commit to nodejs/node that referenced this pull request Aug 26, 2015
per: nodejs/node-v0.x-archive#7944

originally submitted by @oconnore

Minor update to the description in `fs.exists()`

Reviewed By: Sakthipriyan Vairamani <[email protected]>
PR-URL: #2378
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants