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: add ESM and CommonJS examples in fs documentation #52207

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Next Next commit
doc: clean up errors in fs additions
Signed-off-by: Tierney Cyren <hello@bnb.im>
  • Loading branch information
bnb committed Mar 25, 2024
commit 995259ee56639a1c7c44396eb91d6b0c3fb4f520
12 changes: 6 additions & 6 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@
try {
await chmod('my_file.txt', 0o775).then(console.log('The permissions for file "my_file.txt" have been changed!'));
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO it's much more readable as two separate expressions

Suggested change
await chmod('my_file.txt', 0o775).then(console.log('The permissions for file "my_file.txt" have been changed!'));
await chmod('my_file.txt', 0o775);
console.log('The permissions for file "my_file.txt" have been changed!');

} catch {
console.log('The permissions for file "my_file.txt" failed to change!');
console.error('The permissions for file "my_file.txt" failed to change!');
}
```

Expand All @@ -1005,7 +1005,7 @@
try {
await chmod('my_file.txt', 0o775).then(console.log('The permissions for file "my_file.txt" have been changed!'));
} catch {
console.log('The permissions for file "my_file.txt" failed to change!');
console.error('The permissions for file "my_file.txt" failed to change!');
}
}

Expand Down Expand Up @@ -1035,7 +1035,7 @@
try {
await chown('my_file.txt', uid, gid).then(console.log(`Successfully ran chown on my_file.txt to UID ${uid} and GID ${gid}!`));
} catch {
console.log('Failed to chown my_file.txt!');
console.error('Failed to chown my_file.txt!');
}
```

Expand All @@ -1050,7 +1050,7 @@
try {
await chown('my_file.txt', uid, gid).then(console.log(`Successfully ran chown on my_file.txt to UID ${uid} and GID ${gid}!`));
} catch {
console.log('Failed to chown my_file.txt!');
console.error('Failed to chown my_file.txt!');
}
}

Expand Down Expand Up @@ -2436,7 +2436,7 @@
const gid = getgid();

chown('my_file.txt', uid, gid, (err) => {
if (err) throw new Error('Could not chown my_file.txt');
if (err) throw err;

console.log(`Successfully ran chown on my_file.txt to UID ${uid} and GID ${gid}!`);
});
Expand All @@ -2450,7 +2450,7 @@
const gid = getgid();

chown('my_file.txt', uid, gid, (err) => {
if (err) throw new Error('Could not chown my_file.txt');
if (err) throw err ;

Check failure on line 2453 in doc/api/fs.md

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Multiple spaces found before ';'

Check failure on line 2453 in doc/api/fs.md

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Unexpected whitespace before semicolon

console.log(`Successfully ran chown on my_file.txt to UID ${uid} and GID ${gid}!`);
});
Expand Down
Loading