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: improve fs code example quality #46948

Closed

Conversation

jakecastelli
Copy link
Contributor

@jakecastelli jakecastelli commented Mar 4, 2023

  • Fixed code examples that are missing import.
  • Added missing optional chaining operator (otherwise the code example would crash)
  • Renamed variable name to avoid confusing highlight.js reserved keywords from.

Screenshot 2023-03-04 at 10 20 15 pm

@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 Mar 4, 2023
@jakecastelli jakecastelli marked this pull request as ready for review March 4, 2023 12:09
doc/api/fs.md Outdated
Comment on lines 7567 to 7568
const fromDir = '/tmp/hello';
const toDir = '/tmp/world';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this imply that /tmp/hello and /tmp/world are directories? I think, something like

Suggested change
const fromDir = '/tmp/hello';
const toDir = '/tmp/world';
const fromPath = '/tmp/hello';
const toPath = '/tmp/world';

or

Suggested change
const fromDir = '/tmp/hello';
const toDir = '/tmp/world';
const oldPath = '/tmp/hello';
const newPath = '/tmp/world';

would be less confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree 👍 thanks!

fixup
@LiviaMedeiros LiviaMedeiros added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 5, 2023
@@ -7542,6 +7546,8 @@ For example, the following is prone to error because the `fs.stat()`
operation might complete before the `fs.rename()` operation:

```js
const fs = require('node:fs');
Copy link
Contributor

Choose a reason for hiding this comment

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

We would typically need to have two examples here, one ESM and one CJS. (doesn't have to block this PR from landing, but it'd need to happen at some point)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problems, once this PR lands I can work on another PR to make sure all of the fs code examples have js flavor 👌 (at the moment there are many of the examples in fs missing them)

@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Mar 6, 2023
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/46948
FetchError: Invalid response body while trying to fetch https://api.github.com/graphql: Premature close
    at consumeBody (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/node_modules/node-fetch/src/body.js:234:60)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Response.text (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/node_modules/node-fetch/src/body.js:158:18)
    at async Request.json (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/lib/request.js:51:18)
    at async Request.query (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/lib/request.js:109:20)
    at async Request.queryAll (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/lib/request.js:136:20)
    at async Request.gql (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/lib/request.js:66:22)
    at async PRData.getComments (file:///opt/hostedtoolcache/node/18.14.2/x64/lib/node_modules/node-core-utils/lib/pr_data.js:97:21)
    at async Promise.all (index 2)
    at async Promise.all (index 1) {
  type: 'system',
  errno: 'ERR_STREAM_PREMATURE_CLOSE',
  code: 'ERR_STREAM_PREMATURE_CLOSE',
  erroredSysCall: undefined
}
https://github.com/nodejs/node/actions/runs/4343149312

LiviaMedeiros pushed a commit that referenced this pull request Mar 6, 2023
PR-URL: #46948
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
@LiviaMedeiros
Copy link
Contributor

Landed in 070e773

targos pushed a commit that referenced this pull request Mar 13, 2023
PR-URL: #46948
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
targos pushed a commit that referenced this pull request Mar 14, 2023
PR-URL: #46948
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
PR-URL: #46948
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Qingyu Deng <i@ayase-lab.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. 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