1 # fs-exists-sync [![NPM version](https://img.shields.io/npm/v/fs-exists-sync.svg?style=flat)](https://www.npmjs.com/package/fs-exists-sync) [![NPM downloads](https://img.shields.io/npm/dm/fs-exists-sync.svg?style=flat)](https://npmjs.org/package/fs-exists-sync) [![Build Status](https://img.shields.io/travis/jonschlinkert/fs-exists-sync.svg?style=flat)](https://travis-ci.org/jonschlinkert/fs-exists-sync)
3 > Drop-in replacement for `fs.existsSync` with zero dependencies. Other libs I found either have crucial differences from fs.existsSync, or unnecessary dependencies. See README.md for more info.
6 Install with [npm](https://www.npmjs.com/):
9 $ npm install fs-exists-sync --save
15 var exists = require('fs-exists-sync');
17 console.log(exists('.'));
19 console.log(exists(process.cwd()));
21 console.log(exists('README.md'));
23 console.log(exists('foo.txt'));
25 console.log(exists(''));
27 console.log(exists());
31 ## Why another "exists" lib?
33 I just want a _simple replacement for `fs.existsSync`_. Here is what I found:
35 - [path-exists][]: Has dependencies to support a promises API
36 - [fs-exists][]: async only
37 - [file-exists][]: returns `false` if the path exists but is a directory.
38 - [exists][]: nothing to do with `fs`.
44 You might also be interested in these projects:
46 * [is-absolute](https://www.npmjs.com/package/is-absolute): Polyfill for node.js `path.isAbolute`. Returns true if a file path is absolute. | [homepage](https://github.com/jonschlinkert/is-absolute)
47 * [parse-filepath](https://www.npmjs.com/package/parse-filepath): Pollyfill for node.js `path.parse`, parses a filepath into an object. | [homepage](https://github.com/jonschlinkert/parse-filepath)
48 * [try-open](https://www.npmjs.com/package/try-open): Tries to open a file using fs.openSync (only necessary with sync), fails gracefully if the… [more](https://www.npmjs.com/package/try-open) | [homepage](https://github.com/jonschlinkert/try-open)
51 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/fs-exists-sync/issues/new).
54 Generate readme and API documentation with [verb][]:
57 $ npm install verb && npm run docs
60 Or, if [verb][] is installed globally:
67 Install dev dependencies:
70 $ npm install -d && npm test
76 + [github/jonschlinkert](https://github.com/jonschlinkert)
77 + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
80 Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
81 Released under the [MIT license](https://github.com/jonschlinkert/fs-exists-sync/blob/master/LICENSE).
85 _This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on April 09, 2016._
87 [verb]: https://github.com/verbose/verb
88 [path-exists]: https://github.com/sindresorhus/path-exists
89 [fs-exists]: https://github.com/meryn/fs-exists
90 [file-exists]: https://github.com/scottcorgan/file-exists
91 [exists]: https://github.com/tjmehta/exists