1.0.5 • Published 7 years ago

@johnpaulvaughan/promise-it-exists v1.0.5

Weekly downloads
1
License
ISC
Repository
github
Last release
7 years ago

Promise It Exists

Synopsis

This module checks a filepath to confirm the file exists.

Motivation

Node does not have a one-liner for file validation using promises, so I wrote a module to do the job.

##Installation

$ npm install @johnpaulvaughan/promise-it-exists --save

##Code Example Resolves a Promise on success:

let promiseIt = require('@johnpaulvaughan/promise-it-exists');

return promiseIt.exists('testing/good filename.txt')
.then((result) => console.log(result))
.catch((err) = > console.log(err)

// -> 'testing/my good filename.txt'

Rejects with an error on failure:

let promiseIt = require('@johnpaulvaughan/promise-it-exists');
return promiseIt.exists('testing/bad filename.txt')
.then((result) => console.log(result))
.catch((err) = > console.log(err)

// -> Error('File does not exist')