npm-update
npm update
Installment
$ npm i npm-update --save
Usage
const npmUpdate = require('npm-update')
const pkg = require('../package.json')
(async () => {
const { needUpdate } = await npmUpdate({ pkg });
if (needUpdate) return;
})();
If needUpdate
is true
, print message:
╭─────────────────────────────────────────╮
│ │
│ new version x.y.z found │
│ │
│ run npm i name@x -g │
│ │
╰─────────────────────────────────────────╯
Options
const {
needUpdate,
version: latestVersion,
} = await update(options);
- options {Object}
- pkg
Object
package.json object. - host
string
registry host, default is registry.npmjs.org. - timeout
number
request registry timeout, default is 3000ms. - version
string
base version for comparing, can be npm tag or npm version, default is latest. - silent
boolean
if slient is true, will not print message, default is false.
Contributors
This project follows the git-contributor spec, auto updated at Fri Nov 04 2022 13:38:18 GMT+0800
.
License
The MIT License (MIT)