-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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
doc: Provide bad/better examples for access() and exists() #7832
Conversation
@@ -340,6 +340,81 @@ fs.access('/etc/passwd', fs.constants.R_OK | fs.constants.W_OK, (err) => { | |||
}); | |||
``` | |||
|
|||
`fs.access()` should not be used to check if a file exists before using it |
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.
As opposed to saying should not be used
, perhaps something a bit softer...
Using `fs.acess()` to check for the existence of a file before calling `fs.open()`,
`fs.readFile()`, or `fs.writeFile()` is not recommended because doing so...
Thank you for this, left some comments! Sorry it has take so long for someone to take a look and get back to you. |
c3c11b3
to
ccec465
Compare
@jasnell Thanks for your feedback. I've incorporated your comments in the latest draft. |
@dfabulich .. thank you! will be able to go through in detail again tomorrow :-) |
ping @jasnell |
Whoops, let this one slip off my radar. LGTM |
ping @nodejs/documentation |
For example: | ||
|
||
```js | ||
// write: NOT RECOMMENDED |
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.
Maybe split the code blocks and put these pseudo-headings in bold just above them?
LGTM with a suggestion, thanks for putting these together! |
if (!err) { | ||
console.error('myfile already exists'); | ||
return; | ||
} else { |
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.
Drop the else
, we can unindent the next function call.
ccec465
to
80d6ec3
Compare
Incorporated feedback from @addaleax and @thefourtheye |
LGTM! will get this landed! |
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Landed in 143d38c. Thank you! |
PR-URL: nodejs#7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
I've landed this on v4.x-staging as it appears to be accurate. Please let me know if it is not |
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
PR-URL: #7832 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Anna Henningsen <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
doc
Description of change