Complexity Score
Low
Open Issues
N/A
Dependent Projects
237
Weekly Downloadsglobal
2,293,671
License
- MIT
- Yesattribution
- Permissivelinking
- Permissivedistribution
- Permissivemodification
- Nopatent grant
- Yesprivate use
- Permissivesublicensing
- Notrademark grant
Downloads
Readme
update-check
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
- Fork this repository to your own GitHub account and then clone it to your local device
- Link the package to the global module directory:
npm link
- 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
Dependencies
Loading dependencies...
CVE IssuesActive
0
Scorecards Score
3.70
Test Coverage
No Data
Follows Semver
Yes
Github Stars
166
Dependenciestotal
5
DependenciesOutdated
4
DependenciesDeprecated
1
Threat Modelling
No
Repo Audits
No
Learn how to distribute update-check in your own private NPM registry
$npm config set registry
https://npm.cloudsmith.com/owner/repo
/Processing...
✓Done
$npm install update-check
/Processing...
✓Done
12 Releases
NPM on Cloudsmith