package
Minimalistic update notifications for command line interfaces
npm install update-checkGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Estimated unpacked size across 9 packages.
108.0 kB
Includes dependencies.
2 direct · 2 outdated
3.1.0
7.2.0
3.3.2
5.1.1
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...
yarn add update-check...or npm:
npm install update-checkNext, 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.
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
npm linknpm link update-check. Instead of the default one from npm, node will now use your clone.Leo Lamprecht (@notquiteleo) - ZEIT
jamo
jamo@isotalo.fi