Uh oh!
There was an error while loading. Please reload this page.
doc: update examples of the final "callback" argument for fs.access() - #20460
doc: update examples of the final "callback" argument for fs.access()#20460BeniCheni wants to merge 5 commits into
Conversation
There was a problem hiding this comment.
Nits:
and/or->andcould be written to->is writable
There was a problem hiding this comment.
Nit: could not be written to -> is not writable
There was a problem hiding this comment.
is not readable / is readable?
There was a problem hiding this comment.
@vsemozhetbyt Yes, I forgot the not. Should be:
Nit: could not be read -> is not readable
There was a problem hiding this comment.
Nit: could be written to -> is writable
There was a problem hiding this comment.
Same with the comment: could be written to -> is writable
Trott
commented
May 2, 2018
I wonder if the example code can be pared down a bit without losing any information. (I don't know if it can; I'm asking.) @nodejs/documentation @nodejs/fs |
There was a problem hiding this comment.
`package.json` for consistency?
vsemozhetbyt
commented
May 2, 2018
BeniCheni
commented
May 2, 2018
🙏 for 1st round of review @Trott & @vsemozhetbyt. I've read your feedback and updated the content to emphasize contextually more on the suggested "readable" & "writable" keywords in the latest updates. Please review again? I also saw the "pared down a bit" comment, which I'll look out for any further suggested feedback to account for that potential update. (happy to update it to if any suggest arises on that topic) |
There was a problem hiding this comment.
It seems this can be unwrapped now like in the block above, to spare some lines)
@BeniCheni@Trott Minimal changes I could think of (-11 lines without major refactoring): Code:constfile='package.json';// Check if the file exists in the current directory.fs.access(file,fs.constants.F_OK,(err)=>{console.log(`${file}${err ? 'does not exist' : 'exists'}`);});// Check if the file is readable.fs.access(file,fs.constants.R_OK,(err)=>{console.log(`${file}${err ? 'is not readable' : 'is readable'}`);});// Check if the file is writable.fs.access(file,fs.constants.W_OK,(err)=>{console.log(`${file}${err ? 'is not writable' : 'is writable'}`);});// Check if the file exists in the current directory, and if it is writable.fs.access(file,fs.constants.F_OK|fs.constants.W_OK,(err)=>{if(err){console.error(`${file}${err.code==='ENOENT' ? 'does not exist' : 'is read-only'}`);}else{console.log(`${file} exists, and it is writable`);}}); |
vsemozhetbyt
commented
May 2, 2018
(And it seems |
@vsemozhetbyt , nice refactoring suggestion. I worked with the suggested code to update the PR, as well as removed the not so useful |
There was a problem hiding this comment.
We can also replace './package.json' with just file here and in the next calls)
…js examples for fs.access()
BeniCheni
commented
May 2, 2018
Sounds good, @vsemozhetbyt. Updated the |
vsemozhetbyt
commented
May 3, 2018
@Trott Can we land it in this variant? |
Trott
commented
May 3, 2018
@vsemozhetbyt I have no objections. |
vsemozhetbyt
commented
May 4, 2018
(Missed CI-lite link: https://ci.nodejs.org/job/node-test-pull-request-lite/650/) |
vsemozhetbyt
commented
May 4, 2018
Landed in b4ca3a4 |
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesFixes: #17508
Per this following comment (as the origin of the aspiration to help out #17508), I've confirmed with the @ gireeshpunathil, and worked with the suggested content of #17578.
Hope that the attempted
fs.accesssnippets look okay in the PR. Happy to update according to review feedback. Thanks for reviewing in advance.