mirror of
https://github.com/pnpm/pnpm.git
synced 2026-07-02 11:55:17 -04: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.
22 lines
530 B
JavaScript
22 lines
530 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 {}
|
|
}
|
|
},
|
|
save (storeJson) {
|
|
writeFileSync(storeJsonPath, JSON.stringify(storeJson, null, 2), 'utf8')
|
|
}
|
|
}
|
|
}
|