UNPKG

317 BJavaScriptView Raw
1'use strict';
2
3module.exports = function (filepath, defaults) {
4 if (this.exists(filepath)) {
5 try {
6 return JSON.parse(this.read(filepath));
7 } catch (error) {
8 throw new Error('Could not parse JSON in file: ' + filepath + '. Detail: ' + error.message);
9 }
10 } else {
11 return defaults;
12 }
13};