diff --git a/lib/fileUtils.js b/lib/fileUtils.js index 7bde334..f218adb 100644 --- a/lib/fileUtils.js +++ b/lib/fileUtils.js @@ -10,8 +10,14 @@ module.exports = function(fs) { function statFile(filePath) { return new Promise(function(resolve, reject) { fs.stat(filePath, function(err, stat) { - // No rejection here as it is ok if the file was not found - resolve(stat ? {path: filePath, stat: stat} : null); + if (err instanceof Error) { + if (err.code === "ENOENT") { // "File or directory does not exist" + return resolve(null); + } else { + return reject(err); + } + } + resolve(stat ? {path: filePath, stat} : null); }); }); }