Files
pnpm/lib/fs/require_json.js
Zoltan Kochan a9afddacfd Read package.json before updating (#284)
* Read package.json before updating

Using the cached version of package.json can cause ovewriting of changes

close #280

* Skip GitHub test on CI

The GitHub test fails frequently with 403 error with no good no reason
2016-08-09 20:33:39 +03:00

14 lines
354 B
JavaScript

var 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]
}