register.js 374 B

12345678910111213
  1. const fs = require('fs')
  2. const JSON5 = require('./')
  3. // eslint-disable-next-line node/no-deprecated-api
  4. require.extensions['.json5'] = function (module, filename) {
  5. const content = fs.readFileSync(filename, 'utf8')
  6. try {
  7. module.exports = JSON5.parse(content)
  8. } catch (err) {
  9. err.message = filename + ': ' + err.message
  10. throw err
  11. }
  12. }