Skip to content

Commit

Permalink
Fail early when checking async exists
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
scottcorgan committed Mar 8, 2017
1 parent fa89c12 commit d6b9b65
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ function fileExits (filepath, options, done = function () {}) {
options = {}
}

fs.stat(fullPath(filepath, options), (err, stats) => done(err, stats.isFile()))
fs.stat(fullPath(filepath, options), (err, stats) => {
if (err) {
return done(err)
}

done(null, stats.isFile())
})
}

fileExits.sync = function fileExistsSync (filepath = '', options = {}) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "file-exists",
"version": "3.0.1",
"version": "3.0.2",
"description": "Check if filepath exists and is a file",
"main": "index.js",
"directories": {
Expand Down

0 comments on commit d6b9b65

Please sign in to comment.