index.js 422 B

1234567891011
  1. 'use strict';
  2. const path = require('path');
  3. const fs = require('graceful-fs');
  4. const stripBom = require('strip-bom');
  5. const parseJson = require('parse-json');
  6. const pify = require('pify');
  7. const parse = (data, fp) => parseJson(stripBom(data), path.relative('.', fp));
  8. module.exports = fp => pify(fs.readFile)(fp, 'utf8').then(data => parse(data, fp));
  9. module.exports.sync = fp => parse(fs.readFileSync(fp, 'utf8'), fp);