Security update for permissions_by_term
[yaffs-website] / node_modules / path-exists / readme.md
1 # path-exists [![Build Status](https://travis-ci.org/sindresorhus/path-exists.svg?branch=master)](https://travis-ci.org/sindresorhus/path-exists)
2
3 > Check if a path exists
4
5 Because [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), but there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
6
7 Never use this before handling a file though:
8
9 > In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.
10
11
12 ## Install
13
14 ```
15 $ npm install --save path-exists
16 ```
17
18
19 ## Usage
20
21 ```js
22 // foo.js
23 var pathExists = require('path-exists');
24
25 pathExists('foo.js').then(function (exists) {
26         console.log(exists);
27         //=> true
28 });
29 ```
30
31
32 ## API
33
34 ### pathExists(path)
35
36 Returns a promise that resolves to a boolean of whether the path exists.
37
38 ### pathExists.sync(path)
39
40 Returns a boolean of whether the path exists.
41
42
43 ## License
44
45 MIT © [Sindre Sorhus](http://sindresorhus.com)