Created
October 30, 2019 17:16
-
-
Save frdnrdb/692d13f4d9a4a5506533cea11cf2cdf9 to your computer and use it in GitHub Desktop.
Import any fileformat to node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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