Skip to content

Commit 818f084

Browse files
nicolasrestrepotargos
authored andcommitted
doc: add example code for fs.existsSync()
PR-URL: #28354 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 5047006 commit 818f084

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/api/fs.md

+5
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,11 @@ this API: [`fs.exists()`][].
17011701
parameter to `fs.exists()` accepts parameters that are inconsistent with other
17021702
Node.js callbacks. `fs.existsSync()` does not use a callback.
17031703

1704+
```js
1705+
if (fs.existsSync('/etc/passwd')) {
1706+
console.log('The file exists.');
1707+
}
1708+
```
17041709

17051710
## fs.fchmod(fd, mode, callback)
17061711
<!-- YAML

0 commit comments

Comments
 (0)