1. update-check
Minimalistic update notifications for command line interfaces
update-check
Package: update-check
Created by: zeit
Last modified: Fri, 07 Jul 2023 03:54:53 GMT
Version: 1.5.4
License: MIT
Downloads: 7,516,817
Repository: https://github.com/zeit/update-check

Install

npm install update-check
yarn add update-check

update-check

npm version
install size

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.

Usage

Firstly, install the package with yarn...

 yarn add update-check

...or npm:

 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:

 const pkg = require('./package');
const checkForUpdate = require('update-check');

let update = null;

try {
	update = await checkForUpdate(pkg);
} catch (err) {
	console.error(`Failed to check for updates: ${err}`);
}

if (update) {
	console.log(`The latest version is ${update.latest}. Please update!`);
}

That's it! You're done.

Configuration

If you want, you can also pass options to customize the package's behavior:

 const pkg = require('./package');
const checkForUpdate = require('update-check');

let update = null;

try {
	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')
	});
} catch (err) {
	console.error(`Failed to check for updates: ${err}`);
}

if (update) {
	console.log(`The latest version is ${update.latest}. Please update!`);
}

Contributing

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Link the package to the global module directory: npm link
  3. Within the module you want to test your local development instance of the package, just link it: npm link update-check. Instead of the default one from npm, node will now use your clone.

Author

Leo Lamprecht (@notquiteleo) - ZEIT

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin