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
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup
fixup
  • Loading branch information
jakecastelli committed Mar 5, 2023
commit 67da4a314133340110d0c7fc0dc67fb6bf7d20b6
14 changes: 7 additions & 7 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7564,12 +7564,12 @@ of one before invoking the other:
```mjs
import { rename, stat } from 'node:fs/promises';

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

try {
await rename(fromDir, toDir);
const stats = await stat(toDir);
await rename(oldPath, newPath);
const stats = await stat(newPath);
console.log(`stats: ${JSON.stringify(stats)}`);
} catch (error) {
console.error('there was an error:', error.message);
Expand All @@ -7579,10 +7579,10 @@ try {
```cjs
const { rename, stat } = require('node:fs/promises');

(async function(fromDir, toDir) {
(async function(oldPath, newPath) {
try {
await rename(fromDir, toDir);
const stats = await stat(toDir);
await rename(oldPath, newPath);
const stats = await stat(newPath);
console.log(`stats: ${JSON.stringify(stats)}`);
} catch (error) {
console.error('there was an error:', error.message);
Expand Down