mirror of
https://github.com/pnpm/pnpm.git
synced 2026-02-06 13:11:57 -05:00
13 lines
307 B
JavaScript
13 lines
307 B
JavaScript
var cache = {}
|
|
|
|
/*
|
|
* Works identically to require('/path/to/file.json'), but safer.
|
|
*/
|
|
|
|
module.exports = function requireJson (path) {
|
|
path = require('path').resolve(path)
|
|
if (cache[path]) return cache[path]
|
|
cache[path] = JSON.parse(require('fs').readFileSync(path, 'utf-8'))
|
|
return cache[path]
|
|
}
|