@alexbinary/file-exists

1.0.2Β β€’Β PublicΒ β€’Β Published

file-exists

Simple and consistent way to check if a file exists πŸ”Ž

npm GitHub release Build Status dependencies Status devDependencies Status

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

Package Sidebar

Install

npm i @alexbinary/file-exists

Weekly Downloads

1

Version

1.0.2

License

MIT

Last publish

Collaborators

  • alexbinary