|
| 1 | +# github-version-checker |
| 2 | +Simple **version checker** working with **GitHub releases** and the **GitHub API**. |
| 3 | + |
| 4 | +## Install |
| 5 | +```bash |
| 6 | +npm install --save github-version-checker |
| 7 | +``` |
| 8 | + |
| 9 | +## Usage |
| 10 | +### JavaScript |
| 11 | +```javascript |
| 12 | +// require modules |
| 13 | +const versionCheck = require('github-version-checker'); |
| 14 | +const pkg = require('./package.json'); // or whereever your package.json lies |
| 15 | + |
| 16 | +// version check options |
| 17 | +const options = { |
| 18 | + repo: 'axelrindle/github-version-checker', // will be expanded to https://api.github.com/repos/axelrindle/github-version-checker/releases |
| 19 | + currentVersion: pkg.version |
| 20 | +}; |
| 21 | +versionCheck(options, function (update) { // callback function |
| 22 | + if (update) { // print some update info if an update is available |
| 23 | + console.log('An update is available!'); |
| 24 | + console.log('New version: ' + update.tag_name); |
| 25 | + console.log('Details here: ' + update.html_url); |
| 26 | + } |
| 27 | + |
| 28 | + // start your app |
| 29 | + console.log('Starting app...'); |
| 30 | + //... |
| 31 | +}); |
| 32 | +``` |
| 33 | + |
| 34 | +### CoffeeScript |
| 35 | +```coffeescript |
| 36 | +# require modules |
| 37 | +versionCheck = require('github-version-checker') |
| 38 | +pkg = require('./package.json') # or whereever your package.json lies |
| 39 | + |
| 40 | +# version check options |
| 41 | +options = |
| 42 | + repo: 'axelrindle/github-version-checker' |
| 43 | + currentVersion: pkg.version |
| 44 | + |
| 45 | +versionCheck options, (update) -> # callback function |
| 46 | + if update # print some update info if an update is available |
| 47 | + console.log 'An update is available!' |
| 48 | + console.log 'New version: ' + update.tag_name |
| 49 | + console.log 'Details here: ' + update.html_url |
| 50 | + |
| 51 | + # start your app |
| 52 | + console.log 'Starting app...' |
| 53 | + #... |
| 54 | +``` |
| 55 | + |
| 56 | +## The `update` object |
| 57 | +The object you receive in the callback function, follows the format specified here: |
| 58 | +https://developer.github.com/v3/repos/releases/#get-a-single-release |
0 commit comments