From 818f08416c456a33173bfad25d81b00fd0c842f0 Mon Sep 17 00:00:00 2001 From: nicolasrestrepo Date: Fri, 21 Jun 2019 16:46:14 -0500 Subject: [PATCH] doc: add example code for fs.existsSync() PR-URL: https://github.com/nodejs/node/pull/28354 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Trivikram Kamat Reviewed-By: Rich Trott Reviewed-By: James M Snell --- doc/api/fs.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index f1e2bcb60ab98a..50ab633b74d490 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1701,6 +1701,11 @@ this API: [`fs.exists()`][]. parameter to `fs.exists()` accepts parameters that are inconsistent with other Node.js callbacks. `fs.existsSync()` does not use a callback. +```js +if (fs.existsSync('/etc/passwd')) { + console.log('The file exists.'); +} +``` ## fs.fchmod(fd, mode, callback)