file-exists
Simple and consistent way to check if a file exists
Uses @alexbinary/promisify by alexbinary
Install
Install using npm or yarn :
$ npm install @alexbinary/file-exists
# or
$ yarn add @alexbinary/file-exists
Usage
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
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