Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Commit b477619

Browse files
author
Axel Rindle
committed
Token can be read from env variable
1 parent 0217e53 commit b477619

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

examples/token_from_env.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
// register coffeescript
5+
require('coffeescript/register');
6+
7+
const versionCheck = require('../lib/main');
8+
const options = {
9+
repo: 'github-version-checker',
10+
owner: 'axelrindle',
11+
currentVersion: require('../package.json').version
12+
};
13+
14+
versionCheck(options)
15+
.then(update => {
16+
if (update) { // update is null if there is no update available, so check here
17+
console.log("An update is available! " + update.name);
18+
console.log("You are on version " + options.currentVersion + "!");
19+
} else {
20+
console.log("You are up to date.");
21+
}
22+
})
23+
.catch(error => {
24+
console.error(error);
25+
});

lib/main.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ module.exports = (options, callback) ->
3232
###
3333
check = (options, callback) ->
3434
# get options
35-
token = options.token ? ''
35+
token = options.token ? process.env.GITHUB_API_TOKEN ? ''
3636
repo = options.repo ? ''
3737
owner = options.owner ? ''
3838
currentVersion = options.currentVersion ? ''

0 commit comments

Comments
 (0)