mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-14 03:26:13 -04:00
* 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
14 lines
354 B
JavaScript
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]
|
|
}
|