marko/compiler/taglib-loader/json-file-reader.js
Patrick Steele-Idem 59fee06892 MIT license
2017-01-03 15:56:58 -07:00

15 lines
435 B
JavaScript

var fs = require('fs');
var stripJsonComments = require('strip-json-comments');
var fsReadOptions = { encoding: 'utf8' };
exports.readFileSync = function (path) {
var json = fs.readFileSync(path, fsReadOptions);
try {
var taglibProps = JSON.parse(stripJsonComments(json));
return taglibProps;
} catch(e) {
throw new Error('Unable to parse JSON file at path "' + path + '". Error: ' + e);
}
};