update-pkg
Update package.json
Last updated 3 years ago by rem .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install update-pkg 
SYNC missed versions from official npm registry.

update-pkg NPM version NPM downloads Build Status

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

Current Tags

  • 1.2.0                                ...           latest (3 years ago)

7 Versions

  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           3 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
  • 0.1.1                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 9
Dependencies (3)
Dev Dependencies (2)

Copyright 2014 - 2016 © taobao.org |