json.js 314 B

123456789101112131415
  1. 'use strict';
  2. var fs = require('fs');
  3. var stripBom = require('strip-bom');
  4. module.exports = function (module, filename) {
  5. var content = fs.readFileSync(filename, 'utf8');
  6. try {
  7. module.exports = JSON.parse(stripBom(content));
  8. } catch (err) {
  9. err.message = filename + ': ' + err.message;
  10. throw err;
  11. }
  12. };