@unscsprt/package-json-editor

1.0.2 • Public • Published

@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

npm Travis npm

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

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @unscsprt/package-json-editor

Weekly Downloads

105

Version

1.0.2

License

MIT

Unpacked Size

7.59 kB

Total Files

8

Last publish

Collaborators

  • unscsprt