Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

dfabulich
Copy link
Contributor

@dfabulich dfabulich commented Jul 22, 2016

Checklist
  • make -j4 test (UNIX), or vcbuild test nosign (Windows) passes
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

doc

Description of change

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system. labels Jul 22, 2016
@@ -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
Copy link
Member

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...

@jasnell
Copy link
Member

jasnell commented Aug 5, 2016

Thank you for this, left some comments! Sorry it has take so long for someone to take a look and get back to you.

@dfabulich
Copy link
Contributor Author

@jasnell Thanks for your feedback. I've incorporated your comments in the latest draft.

@jasnell
Copy link
Member

jasnell commented Aug 11, 2016

@dfabulich .. thank you! will be able to go through in detail again tomorrow :-)

@Fishrock123
Copy link
Contributor

ping @jasnell

@jasnell
Copy link
Member

jasnell commented Aug 22, 2016

Whoops, let this one slip off my radar. LGTM

@jasnell
Copy link
Member

jasnell commented Aug 24, 2016

ping @nodejs/documentation

For example:

```js
// write: NOT RECOMMENDED
Copy link
Member

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?

@addaleax
Copy link
Member

LGTM with a suggestion, thanks for putting these together!

if (!err) {
console.error('myfile already exists');
return;
} else {
Copy link
Contributor

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.

@dfabulich
Copy link
Contributor Author

Incorporated feedback from @addaleax and @thefourtheye

@jasnell
Copy link
Member

jasnell commented Sep 1, 2016

LGTM! will get this landed!

jasnell pushed a commit that referenced this pull request Sep 1, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@jasnell
Copy link
Member

jasnell commented Sep 1, 2016

Landed in 143d38c. Thank you!

@jasnell jasnell closed this Sep 1, 2016
@Fishrock123 Fishrock123 mentioned this pull request Sep 6, 2016
Fishrock123 pushed a commit to Fishrock123/node that referenced this pull request Sep 8, 2016
PR-URL: nodejs#7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
Fishrock123 pushed a commit that referenced this pull request Sep 9, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Sep 30, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins
Copy link
Contributor

I've landed this on v4.x-staging as it appears to be accurate. Please let me know if it is not

MylesBorins pushed a commit that referenced this pull request Oct 10, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
rvagg pushed a commit that referenced this pull request Oct 18, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
MylesBorins pushed a commit that referenced this pull request Oct 26, 2016
PR-URL: #7832
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Oct 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants