Files
pnpm/lib/fs/store_json_controller.js
Zoltan Kochan b19369407a fix: don't use ! as a delimiter in the store
! can be part of a valid npm package name. Use + as a
delimiter instead.

close #276, PR #320

BREAKING CHANGE:

Stores created with the ! delimiter are not compatible
with the new version that uses +.

Any store created by older versions of pnpm has to be
removed and reinstalled.
2016-08-28 15:33:07 +03:00

22 lines
532 B
JavaScript

'use strict'
const join = require('path').join
const writeFileSync = require('fs').writeFileSync
const readFileSync = require('fs').readFileSync
module.exports = function storeJsonController (storePath) {
const storeJsonPath = join(storePath, 'store.json')
return {
read () {
try {
return JSON.parse(readFileSync(storeJsonPath, 'utf8'))
} catch (err) {
return null
}
},
save (storeJson) {
writeFileSync(storeJsonPath, JSON.stringify(storeJson, null, 2), 'utf8')
}
}
}