Skip to content

Commit d4549e7

Browse files
nicolasrestrepoTrott
authored andcommitted
doc: add example code for fs.existsSync()
PR-URL: #28354 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent c1ee668 commit d4549e7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/fs.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1763,6 +1763,11 @@ this API: [`fs.exists()`][].
17631763
parameter to `fs.exists()` accepts parameters that are inconsistent with other
17641764
Node.js callbacks. `fs.existsSync()` does not use a callback.
17651765

1766+
```js
1767+
if (fs.existsSync('/etc/passwd')) {
1768+
console.log('The file exists.');
1769+
}
1770+
```
17661771

17671772
## fs.fchmod(fd, mode, callback)
17681773
<!-- YAML

0 commit comments

Comments
 (0)