This repository was archived by the owner on Dec 19, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Home
Axel Rindle edited this page May 2, 2020
·
7 revisions
// require modules
const versionCheck = require('github-version-checker');
const pkg = require('./package.json'); // or whereever your package.json lies
// version check options (for details see below)
const options = {
token: 'PUT-YOUR-TOKEN-HERE', // personal access token
repo: 'github-version-checker', // repository name
owner: 'axelrindle', // repository owner
currentVersion: pkg.version, // your app's current version
fetchTags: false // whether to fetch releases or tags
};
versionCheck(options, function (error, update) { // callback function
if (error) throw error;
if (update) { // print some update info if an update is available
console.log('An update is available! ' + update.name);
}
// start your app
console.log('Starting app...');
//...
});Check the examples folder for more examples.
As of v2.0.0 you can supply an access token for working with Github's GraphQL API. This token may be supplied directly via the options object, OR it can be supplied using an environment variable called GITHUB_API_TOKEN.
Consider using this method when working in a private environment, as it reduces traffic and increases the checking speed.
Always try to follow a clear semver format. This helps to avoid parsing mistakes and getting a clear result. Also read here.