1.0.2 • Published 4 years ago
@unscsprt/package-json-editor v1.0.2
@unscsprt/package-json-editor
This is a fork of package-json-editor so we can publish new versions to NPM.
npm package editor that preserve newline and indentation
This is a mere wrapper around automerge
so that we can use to edit npm package tree and preserve all the indentation, newline settings.
We can use this package to edit the tree directly using .set()
method or we can edit the tree object directly and merge the new tree onto the old tree later with .merge()
.
Usage
var packageJsonEditor = require('package-json-editor')
var originTree = fs.readFileSync('./package.json', 'utf-8')
var mutated = JSON.parse(originTree)
mutated.dependencies.debug = '^1.0.0'
mutated.description = 'new description'
delete mutated.license
var newTree = packageJsonEditor(originTree)
.merge(mutated)
.toString()
// or
var anotherTree = packageJsonEditor(originTree)
.set('dependencies.detect-indent', '^5.0.1')
.toJSON()
API
License
1.0.2
4 years ago