Name: update-check
Owner: ZEIT
Description: Minimalistic update notifications for command line interfaces
Created: 2018-04-07 02:32:40.0
Updated: 2018-05-22 22:36:39.0
Pushed: 2018-05-23 21:58:50.0
Homepage: https://npmjs.com/update-check
Size: 26
Language: JavaScript
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This is a very minimal approach to update checking for globally installed packages.
Because it's so simple, the error surface is very tiny and your user's are guaranteed to receive the update message if there's a new version.
You can read more about the reasoning behind this project here.
Firstly, install the package with yarn…
add update-check
…or npm:
install update-check
Next, initialize it.
If there's a new update available, the package will return the content of latest version's package.json
file:
t pkg = require('./package');
t checkForUpdate = require('update-check');
update = null;
{
update = await checkForUpdate(pkg);
tch (err) {
console.error(`Failed to check for updates: ${err}`);
update) {
console.log(`The latest version is ${update.latest}. Please update!`);
That's it! You're done.
If you want, you can also pass options to customize the package's behavior:
t pkg = require('./package');
t checkForUpdate = require('update-check');
update = null;
{
update = await checkForUpdate(pkg, {
interval: 3600000, // For how long to cache latest version (default: 1 day)
distTag: 'canary' // A npm distribution tag for comparision (default: 'latest')
});
tch (err) {
console.error(`Failed to check for updates: ${err}`);
update) {
console.log(`The latest version is ${update.latest}. Please update!`);
npm link
npm link update-check
. Instead of the default one from npm, node will now use your clone.Leo Lamprecht (@notquiteleo) - ZEIT