Package Exports
- update-pkg
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (update-pkg) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
update-pkg

Update package.json
Install
$ npm install --save update-pkg
Usage
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(/* ... */)
API
new Pkg(cwd, [options])
Return a new Pkg instance and would resolve package.json
located at cwd
folder. Default cwd
is ./
.
options
create
Type: boolean
Default: false
Create package.json
when it does not exist, otherwise it will throw an error.
.data
Type: object
Default: {}
The parsed content of package.json
.
.set(keyPath, value)
Set value by the given keyPath
like author.name
and value
like EGOIST
.
.update(keyPath, updater)
updater
is the function to produce the updated value.
.append(keyPath, value)
Append a value
to specific keyPath.
.preppend(keyPath, value)
Prepend a value
to specific keyPath.
.get(keyPath)
Get value by the given keyPath.
.save()
Type: function
Return: Promise
Save data to package.json
.
.saveSync()
Type: function
Return: this
Save data to package.json
but synchronously.
License
MIT © EGOIST