Skip to content

Commit c380ac6

Browse files
benjamingrtellnes
authored andcommitted
doc: suggest alternatives to deprecated APs
At the moment users who want to use `fs.exists` get a warning that the method is deprecated but do not get offered an alternative in the page. This PR suggests `fs.stat` and `fs.access` as alternatives while keeping the warning about the use case in place. Fixes: #1002 PR-URL: #1007 Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Christian Tellnes <christian@tellnes.no>
1 parent 2b47fd2 commit c380ac6

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

doc/api/fs.markdown

+9-3
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,10 @@ callback, and have some fallback logic if it is null.
642642

643643
## fs.exists(path, callback)
644644

645+
`fs.exists()` is **deprecated**. For supported alternatives please check out
646+
[`fs.stat`](fs.html#fs_fs_stat_path_callback) or
647+
[`fs.access`](fs.html#fs_fs_access_path_mode_callback).
648+
645649
Test whether or not the given path exists by checking with the file system.
646650
Then call the `callback` argument with either true or false. Example:
647651

@@ -657,13 +661,15 @@ that leaves you vulnerable to race conditions: another process may remove the
657661
file between the calls to `fs.exists()` and `fs.open()`. Just open the file
658662
and handle the error when it's not there.
659663

660-
`fs.exists()` is **deprecated**.
664+
661665

662666
## fs.existsSync(path)
663667

664-
Synchronous version of `fs.exists`.
668+
Synchronous version of [`fs.exists`](fs.html#fs_fs_exists_path_callback).
665669

666-
`fs.existsSync()` is **deprecated**.
670+
`fs.existsSync()` is **deprecated**. For supported alternatives please check
671+
out [`fs.statSync`](fs.html#fs_fs_statsync_path) or
672+
[`fs.accessSync`](fs.html#fs_fs_accesssync_path_mode).
667673

668674
## fs.access(path[, mode], callback)
669675

0 commit comments

Comments
 (0)