Skip to content

Instantly share code, notes, and snippets.

@frdnrdb
Created October 30, 2019 17:16
Show Gist options
  • Save frdnrdb/692d13f4d9a4a5506533cea11cf2cdf9 to your computer and use it in GitHub Desktop.
Save frdnrdb/692d13f4d9a4a5506533cea11cf2cdf9 to your computer and use it in GitHub Desktop.
Import any fileformat to node
const fs = require('fs')
const JSON5 = require('./')
// eslint-disable-next-line node/no-deprecated-api
require.extensions['.json5'] = function (module, filename) {
const content = fs.readFileSync(filename, 'utf8')
try {
module.exports = JSON5.parse(content)
} catch (err) {
err.message = filename + ': ' + err.message
throw err
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment