https://github.com/alexbinary/file-exists
Simple and consistent way to check if a file exists 🔎
https://github.com/alexbinary/file-exists
Last synced: 4 months ago
JSON representation
Simple and consistent way to check if a file exists 🔎
- Host: GitHub
- URL: https://github.com/alexbinary/file-exists
- Owner: alexbinary
- License: mit
- Created: 2016-12-05T05:03:43.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-12-29T10:45:01.000Z (over 8 years ago)
- Last Synced: 2025-02-23T19:42:24.752Z (4 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# file-exists
Simple and consistent way to check if a file exists 🔎
[](https://www.npmjs.com/package/@alexbinary/file-exists)
[](https://github.com/alexbinary/file-exists/releases/latest)
[](https://travis-ci.org/alexbinary/file-exists)
[](https://david-dm.org/alexbinary/file-exists)
[](https://david-dm.org/alexbinary/file-exists?type=dev)Uses [@alexbinary/promisify](https://www.npmjs.com/package/@alexbinary/promisify) by [alexbinary](https://www.npmjs.com/~alexbinary)
## Install
Install using npm or yarn :
```bash
$ npm install @alexbinary/file-exists
# or
$ yarn add @alexbinary/file-exists
```## Usage
```javascript
let fileexists = require('@alexbinary/file-exists')// callback
fileexists('/path/to/file', (err, exists) => {
console.log('file exists: ' + (exists ? 'yes' : 'no'))
})// promise
fileexists('/path/to/file').then((exists) => {
console.log('file exists: ' + (exists ? 'yes' : 'no'))
})// sync
let exists = fileexists.sync('/path/to/file')
console.log('file exists: ' + (exists ? 'yes' : 'no'))
```## Documentation
```javascript
let fileexists = require('@alexbinary/file-exists')
```### fileexists(filepath)
Checks if a file exists at `filepath`.
This method supports both Promise and node callback style, and resolves with a `boolean` `true` if the file exists, `false` otherwise.
### fileexists.sync(filepath)
Synchronous version. Return `boolean` `true` if the file exists, `false` otherwise.
## License
MIT