GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: add fsPromises.readFile() example by bnb · Pull Request #40237 · nodejs/node

Conversation

@bnb

@bnb bnb commented Sep 27, 2021

Copy link
Copy Markdown
Member

Adds a CJS and MJS example to the readFile method on fsPromises. There is an example with AbortController but it's slightly misleading if you're just looking at the examples, since you don't actually need to do that.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module. labels Sep 27, 2021
aduh95
aduh95 reviewed Sep 27, 2021
View reviewed changes

@aduh95 aduh95 left a comment

Copy link
Copy Markdown
Contributor

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.

I wonder if an example showing how to read a package.json relative to the current module wouldn't be more common than from an absolute path.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@bnb

bnb commented Oct 20, 2021

Copy link
Copy Markdown
Member Author

Would love a second opinion on whether or not we'd prefer to use path in this code example. Personally I like to try to stay away from layering on additional concepts for examples, but if it's the preferred approach of the project I'd be happy to do it.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mhdawson

mhdawson commented Oct 20, 2021

Copy link
Copy Markdown
Member

I see path.join is already used in the same file for other examples. I don't have a strong preference but I would lean towards using the path.join version suggested.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnb

bnb commented Oct 20, 2021

Copy link
Copy Markdown
Member Author

(going to pull and make some small tweaks)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Oct 24, 2021
View reviewed changes
@bnb
doc: add fsPromises.readFile() example
a580c73
Signed-off-by: Tierney Cyren <[email protected]>
@bnb
bnb force-pushed the bnb/add-fspromises-readfile-example branch from 39ec877 to a580c73 Compare November 15, 2021 22:23
@bnb

bnb commented Nov 15, 2021

Copy link
Copy Markdown
Member Author

force pushed to fix prefix issues. hopefully mergable now :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnb

bnb commented Nov 16, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member Author

it looks like this line is over 80 characters. Do we block on that for code examples?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Nov 21, 2021
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Nov 21, 2021
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Trott
Trott reviewed Nov 21, 2021
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnb and others added 3 commits October 10, 2022 19:03
@bnb @Trott
doc: simplify code example
4805e1c
Co-authored-by: Rich Trott <[email protected]>
@bnb @Trott
doc: simplify code example
88b8b08
Co-authored-by: Rich Trott <[email protected]>
@bnb @Trott
doc: remove unnecessary line break
9dfe016
Co-authored-by: Rich Trott <[email protected]>
aduh95
aduh95 reviewed Oct 10, 2022
View reviewed changes
Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread doc/api/fs.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

bnb and others added 3 commits October 11, 2022 00:03
@bnb @aduh95
doc: fix line length issue
410da55
Co-authored-by: Antoine du Hamel <[email protected]>
@bnb @aduh95
doc: use node: prefix for node modules
bad05dd
Co-authored-by: Antoine du Hamel <[email protected]>
@bnb @aduh95
doc: use node: prefix for node modules
90a7717
Co-authored-by: Antoine du Hamel <[email protected]>
aduh95
aduh95 approved these changes Oct 11, 2022
View reviewed changes
@aduh95 aduh95 added the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 11, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 11, 2022
@nodejs-github-bot

nodejs-github-bot commented Oct 11, 2022

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/40237
✔  Done loading data for nodejs/node/pull/40237
----------------------------------- PR info ------------------------------------
Title      doc: add fsPromises.readFile() example (#40237)
Author     Tierney Cyren  (@bnb)
Branch     bnb:bnb/add-fspromises-readfile-example -> nodejs:main
Labels     doc, fs
Commits    7
 - doc: add fsPromises.readFile() example
 - doc: simplify code example
 - doc: simplify code example
 - doc: remove unnecessary line break
 - doc: fix line length issue
 - doc: use `node:` prefix for node modules
 - doc: use `node:` prefix for node modules
Committers 2
 - Tierney Cyren 
 - GitHub 
PR-URL: https://github.com/nodejs/node/pull/40237
Reviewed-By: James M Snell 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/40237
Reviewed-By: James M Snell 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Mon, 27 Sep 2021 23:22:52 GMT
   ✔  Approvals: 2
   ✔  - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/40237#pullrequestreview-787530318
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/40237#pullrequestreview-1136672708
   ✔  Last GitHub CI successful
   ℹ  Green GitHub CI is sufficient
--------------------------------------------------------------------------------
   ✔  No git cherry-pick in progress
   ✔  No git am in progress
   ✔  No git rebase in progress
--------------------------------------------------------------------------------
- Bringing origin/main up to date...
From https://github.com/nodejs/node
 * branch                  main       -> FETCH_HEAD
✔  origin/main is now up-to-date
- Downloading patch for 40237
From https://github.com/nodejs/node
 * branch                  refs/pull/40237/merge -> FETCH_HEAD
✔  Fetched commits as 1124558b655c..90a77178015a
--------------------------------------------------------------------------------
Auto-merging doc/api/fs.md
[main 5a063004ea] doc: add fsPromises.readFile() example
 Author: Tierney Cyren 
 Date: Mon Nov 15 17:22:46 2021 -0500
 1 file changed, 26 insertions(+)
Auto-merging doc/api/fs.md
[main c10f6c3798] doc: simplify code example
 Author: Tierney Cyren 
 Date: Mon Oct 10 19:03:27 2022 +0200
 1 file changed, 2 insertions(+), 1 deletion(-)
Auto-merging doc/api/fs.md
[main 92f98b36c4] doc: simplify code example
 Author: Tierney Cyren 
 Date: Mon Oct 10 19:03:44 2022 +0200
 1 file changed, 2 insertions(+), 1 deletion(-)
Auto-merging doc/api/fs.md
[main 40cef2f085] doc: remove unnecessary line break
 Author: Tierney Cyren 
 Date: Mon Oct 10 19:03:59 2022 +0200
 1 file changed, 1 deletion(-)
Auto-merging doc/api/fs.md
[main 496078fb77] doc: fix line length issue
 Author: Tierney Cyren 
 Date: Tue Oct 11 00:03:02 2022 +0200
 1 file changed, 3 insertions(+), 1 deletion(-)
Auto-merging doc/api/fs.md
[main 366bef88c7] doc: use `node:` prefix for node modules
 Author: Tierney Cyren 
 Date: Tue Oct 11 00:03:25 2022 +0200
 1 file changed, 1 insertion(+), 1 deletion(-)
Auto-merging doc/api/fs.md
[main 19a6ba1076] doc: use `node:` prefix for node modules
 Author: Tierney Cyren 
 Date: Tue Oct 11 00:03:35 2022 +0200
 1 file changed, 2 insertions(+), 2 deletions(-)
   ✔  Patches applied
There are 7 commits in the PR. Attempting autorebase.
Rebasing (2/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: add fsPromises.readFile() example

Signed-off-by: Tierney Cyren [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD c0e2cc46ab] doc: add fsPromises.readFile() example
Author: Tierney Cyren [email protected]
Date: Mon Nov 15 17:22:46 2021 -0500
1 file changed, 26 insertions(+)
Rebasing (3/14)
Rebasing (4/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: simplify code example

Co-authored-by: Rich Trott [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD cead95bac5] doc: simplify code example
Author: Tierney Cyren [email protected]
Date: Mon Oct 10 19:03:27 2022 +0200
1 file changed, 2 insertions(+), 1 deletion(-)
Rebasing (5/14)
Rebasing (6/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: simplify code example

Co-authored-by: Rich Trott [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD 054aac7cd5] doc: simplify code example
Author: Tierney Cyren [email protected]
Date: Mon Oct 10 19:03:44 2022 +0200
1 file changed, 2 insertions(+), 1 deletion(-)
Rebasing (7/14)
Rebasing (8/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: remove unnecessary line break

Co-authored-by: Rich Trott [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD 0e0e2ec4cd] doc: remove unnecessary line break
Author: Tierney Cyren [email protected]
Date: Mon Oct 10 19:03:59 2022 +0200
1 file changed, 1 deletion(-)
Rebasing (9/14)
Rebasing (10/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: fix line length issue

Co-authored-by: Antoine du Hamel [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD ccf76fe1ae] doc: fix line length issue
Author: Tierney Cyren [email protected]
Date: Tue Oct 11 00:03:02 2022 +0200
1 file changed, 3 insertions(+), 1 deletion(-)
Rebasing (11/14)
Rebasing (12/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: use node: prefix for node modules

Co-authored-by: Antoine du Hamel [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD 364aa384c5] doc: use node: prefix for node modules
Author: Tierney Cyren [email protected]
Date: Tue Oct 11 00:03:25 2022 +0200
1 file changed, 1 insertion(+), 1 deletion(-)
Rebasing (13/14)
Rebasing (14/14)

Executing: git node land --amend --yes
--------------------------------- New Message ----------------------------------
doc: use node: prefix for node modules

Co-authored-by: Antoine du Hamel [email protected]
PR-URL: #40237
Reviewed-By: James M Snell [email protected]
Reviewed-By: Antoine du Hamel [email protected]

[detached HEAD 256f3fc2f2] doc: use node: prefix for node modules
Author: Tierney Cyren [email protected]
Date: Tue Oct 11 00:03:35 2022 +0200
1 file changed, 2 insertions(+), 2 deletions(-)

Successfully rebased and updated refs/heads/main.

ℹ Add commit-queue-squash label to land the PR as one commit, or commit-queue-rebase to land as separate commits.

https://github.com/nodejs/node/actions/runs/3223732038

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot nodejs-github-bot added the commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. label Oct 11, 2022
@aduh95 aduh95 added commit-queue PRs queued for automated landing through the Commit Queue. commit-queue-squash PRs the Commit Queue should land as one squashed commit. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. labels Oct 11, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Oct 11, 2022
@nodejs-github-bot
nodejs-github-bot merged commit 624dadb into nodejs:main Oct 11, 2022
@nodejs-github-bot

nodejs-github-bot commented Oct 11, 2022

Copy link
Copy Markdown
Collaborator

Landed in 624dadb

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

danielleadams pushed a commit that referenced this pull request Oct 11, 2022
@bnb @danielleadams
doc: add fsPromises.readFile() example
ce3cb29
Signed-off-by: Tierney Cyren <[email protected]>
PR-URL: #40237
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@danielleadams danielleadams mentioned this pull request Oct 11, 2022
v18.11.0 proposal #44968
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@Trott Trott Trott left review comments
@jasnell jasnell jasnell approved these changes
@aduh95 aduh95 aduh95 approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

commit-queue-squash PRs the Commit Queue should land as one squashed commit. doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@bnb @mhdawson @nodejs-github-bot @jasnell @Trott @aduh95
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.