mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-04 20:21:27 -05:00
Use lebab to transpile ES5 code to ES6. Use eslint to fix styling issues afterwards. Run all js in strict mode to allow let/const in Node 4.
15 lines
369 B
JavaScript
15 lines
369 B
JavaScript
'use strict'
|
|
const cache = {}
|
|
|
|
/*
|
|
* Works identically to require('/path/to/file.json'), but safer.
|
|
*/
|
|
|
|
module.exports = function requireJson (path, opts) {
|
|
opts = opts || {}
|
|
path = require('path').resolve(path)
|
|
if (!opts.ignoreCache && cache[path]) return cache[path]
|
|
cache[path] = JSON.parse(require('fs').readFileSync(path, 'utf-8'))
|
|
return cache[path]
|
|
}
|