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

added few more examples to fs.access. Fixes #17508 #17578

Closed
wants to merge 3 commits into from
Closed

added few more examples to fs.access. Fixes #17508 #17578

wants to merge 3 commits into from

Conversation

mfaheemakhtar
Copy link

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines
Affected core subsystem(s)

@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 Dec 9, 2017
@Trott
Copy link
Member

Trott commented Dec 10, 2017

Hi, @mfaheemakhtar! Welcome and thanks for the pull request!

The text explanations have a number of very small issues but rather than enumerate them, I'm wondering if any of the explanatory text you added is necessary. I wonder if it all might be better as code comments in the examples you provide. For example, perhaps the first code sample could go from this:

fs.access('./package.json', fs.constants.F_OK, (err) => {
  console.log(err ? 'No package.json file!' : 'package.json exists!');
});

...to this:

// Check if `package.json` exists in the current directory.
fs.access('./package.json', fs.constants.F_OK, (err) => {
  console.log(err ? 'No package.json file!' : 'package.json exists!');
});

With the comment there, the two preceding sentences aren't needed anymore. The code is instead explained in the comments.

What do you think?

@mfaheemakhtar
Copy link
Author

mfaheemakhtar commented Dec 10, 2017

Hi @Trott , great idea! I'll improve the pull request.

Thanks for the suggestion.

UPDATE: I've made few changes. I would love to hear your feedback.

doc/api/fs.md Outdated
`/etc/passwd` can be read and written by the current process.
argument will be populated.

The following examples explains the use of different fs.constants.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this sentence too. If you do wish to keep it, please change explains to explain and surround fs.constants with `.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I've removed the text. Any more feedback?

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of smaller issues, but in general LGTM

```js
// Check if we can write to `package.json` file.
fs.access('./package.json', fs.constants.W_OK, (err) => {
console.log(err ? 'You cannot write to package.json.' : 'You can write to package.json.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line length > 80

if(err) {
if(err.code === 'ENOENT')
console.error("File does not exist.");
if(err.code === 'EPERM')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace after the if in if(.

if(err)
console.error("Either the file does not exist or it is read-only.");
else
console.log("The file exists. You can write to the file.");
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example is pretty redundant as the only difference is checking for the error code. It should be obvious from the example above what to do.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @BridgeAR. I appreciate your feedback.

});
```

```js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is all about examples, we could actually use a single JS block that includes all the different examples. But that might just be my personal preference.

@BridgeAR
Copy link
Member

@tabulatedreams thanks again for your PR. Great that you are helping out! Just some hints about how to make things easier, I recommend to run make lint. In this case you actually only have to run the documentation part (you find all the different options in the Makefile) but in general it is good to test everything.
Besides that, you might want to have another look at the commit guidelines and add the subsystem to your commit message. But that is not so important and can be done while landing as well.

```

```js
// Check if we can read `package.json` file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using informal pronouns like "we" in the docs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...so maybe Check if package.json file can be read or something similar to that...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jasnell and @Trott, I'm learning a lot of things. I'll keep these things in my mind.

@joyeecheung
Copy link
Member

joyeecheung commented Jan 17, 2018

Ping @mfaheemakhtar, can you address the reviews and update this PR? Also looks like it needs a rebase. Thanks!

@mfaheemakhtar
Copy link
Author

Sorry @joyeecheung, I had completely forgotten about this. Unfortunately, I am very busy nowadays and can't review and/or update PR. You can consider this PR as outdated and can be rejected/deleted.

Thank you. :)

@joyeecheung joyeecheung added the stalled Issues and PRs that are stalled. label Jan 17, 2018
@joyeecheung
Copy link
Member

joyeecheung commented Jan 17, 2018

@mfaheemakhtar Sorry to hear that. I'll close this one out at the moment but if anyone in this thread wants to pursue this feel free to reopen or submit another PR.

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. stalled Issues and PRs that are stalled.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants