Skip to content

Commit

Permalink
Fix Promise error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
RobLoach committed Sep 27, 2017
1 parent e1be664 commit e8ddb7f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ function fileExists (filepath, options, done) {
}

if (!done) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
fs.stat(fullPath(filepath, options), (err, stats) => {
if (err) {
return resolve(err.code === 'ENOENT' ? false : err)
return err.code === 'ENOENT'
? resolve(false)
: reject(err)
}
resolve(stats.isFile())
})
Expand Down

0 comments on commit e8ddb7f

Please sign in to comment.