Update package.json
$ npm install --save update-pkg
const Pkg = require('update-pkg')
const pkg = new Pkg()
pkg.data //=> package.json object
pkg.set('author.name', 'EGOIST')
pkg.saveSync()
// or Promise
pkg.save().then(/* ... */)
Return a new Pkg instance and would resolve package.json
located at cwd
folder. Default cwd
is ./
.
Type: boolean
Default: false
Create package.json
when it does not exist, otherwise it will throw an error.
Type: object
Default: {}
The parsed content of package.json
.
Set value by the given keyPath
like author.name
and value
like EGOIST
.
updater
is the function to produce the updated value.
Append a value
to specific keyPath.
Prepend a value
to specific keyPath.
Get value by the given keyPath.
Type: function
Return: Promise
Save data to package.json
.
Type: function
Return: this
Save data to package.json
but synchronously.
MIT © EGOIST