Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zeit/update-check
Minimalistic update notifications for command line interfaces
https://github.com/zeit/update-check
checker notification package update
Last synced: 3 months ago
JSON representation
Minimalistic update notifications for command line interfaces
- Host: GitHub
- URL: https://github.com/zeit/update-check
- Owner: vercel
- License: mit
- Created: 2018-04-07T02:32:40.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-18T09:36:58.000Z (about 4 years ago)
- Last Synced: 2024-04-14T16:23:29.610Z (7 months ago)
- Topics: checker, notification, package, update
- Language: JavaScript
- Homepage: https://npmjs.com/update-check
- Size: 26.4 KB
- Stars: 157
- Watchers: 9
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-npm - update-check - 版本更新检查模块 (3. 命令行程序 / 3.1 开发库)
README
# update-check
[![npm version](https://img.shields.io/npm/v/update-check.svg)](https://www.npmjs.com/package/update-check)
[![install size](https://packagephobia.now.sh/badge?p=update-check)](https://packagephobia.now.sh/result?p=update-check)This is a very minimal approach to update checking for [globally installed](https://docs.npmjs.com/getting-started/installing-npm-packages-globally) 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](https://twitter.com/notquiteleo/status/983193273224200192).
## Usage
Firstly, install the package with [yarn](https://yarnpkg.com/en/)...
```bash
yarn add update-check
```...or [npm](https://www.npmjs.com/):
```bash
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:
```js
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:
```js
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](https://help.github.com/articles/fork-a-repo/) this repository to your own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) 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](https://x.com/leo)) - [Vercel](https://vercel.com)