Skip to content

Commit

Permalink
fix: error handling for reading package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
tabrindle committed Jan 18, 2018
1 parent 5024d96 commit 640528e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@ function uniq(arr) {
}

function requireJson(filePath) {
if (fs.existsSync(filePath)) return require(filePath);
var packageJson;
if (fs.existsSync(filePath)) {
try {
packageJson = require(filePath);
} catch (e) {
return false;
}
return packageJson;
}
return false;
}

Expand Down

0 comments on commit 640528e

Please sign in to comment.