require.js 604 B

123456789101112131415161718
  1. // require.js
  2. // Node.js only: adds a require() hook for .json5 files, just like the native
  3. // hook for .json files.
  4. //
  5. // Usage:
  6. // require('json5/require');
  7. // require('./foo'); // will check foo.json5 after foo.js, foo.json, etc.
  8. // require('./bar.json5');
  9. var FS = require('fs');
  10. var JSON5 = require('./json5');
  11. // Modeled off of (v0.6.18 link; check latest too):
  12. // https://github.com/joyent/node/blob/v0.6.18/lib/module.js#L468-L472
  13. require.extensions['.json5'] = function (module, filename) {
  14. var content = FS.readFileSync(filename, 'utf8');
  15. module.exports = JSON5.parse(content);
  16. };