This repository was archived by the owner on Dec 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33The future is now! Futuristic approach leveraging top-level await.
44
55``` js showLineNumbers title="src/util/version-check.js"
6- const versionCheck = require (' github-version-checker' )
6+ const versionCheck = require (' @ github-version-checker/core ' )
77const options = {
88 // token: '...',
99 repo: ' github-version-checker' ,
@@ -13,7 +13,7 @@ const options = {
1313
1414try {
1515 // highlight-next-line
16- const update = await versionCheck (options)
16+ const { update } = await versionCheck (options)
1717 if (update) { // update is null if there is no update available, so check here
1818 console .log (' An update is available! ' + update .name )
1919 console .log (' You are on version ' + options .currentVersion + ' !' )
Original file line number Diff line number Diff line change 33Using a plain old callback.
44
55```` js showLineNumbers title="src/util/version-check.js"
6- const versionCheck = require (' github-version-checker' )
6+ const versionCheck = require (' @ github-version-checker/core ' )
77const options = {
88 // token: '...',
99 repo: ' github-version-checker' ,
1010 owner: ' axelrindle' ,
1111 currentVersion: require (' ../package.json' ).version
1212}
1313
14- versionCheck (options, function (error , update ) {
14+ versionCheck (options, function (error , result ) {
1515 if (error) {
1616 console .error (error)
1717 process .exit (- 1 )
1818 }
1919
20+ const { update } = result
2021 if (update) {
2122 console .log (' An update is available! ' + update .name )
2223 console .log (' You are on version ' + options .currentVersion + ' !' )
Original file line number Diff line number Diff line change 33Modern version using a Promise-based approach.
44
55``` js showLineNumbers title="src/util/version-check.js"
6- const versionCheck = require (' github-version-checker' )
6+ const versionCheck = require (' @ github-version-checker/core ' )
77const options = {
88 // token: '...',
99 repo: ' github-version-checker' ,
@@ -12,7 +12,8 @@ const options = {
1212}
1313
1414versionCheck (options)
15- .then (function (update ) {
15+ .then (function (result ) {
16+ const { update } = result
1617 if (update) { // update is null if there is no update available, so check here
1718 console .log (' An update is available! ' + update .name )
1819 console .log (' You are on version ' + options .currentVersion + ' !' )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ releases api won't work.
66Fetch the tags instead by setting ` fetchTags ` to ` true ` :
77
88``` js showLineNumbers title="src/util/version-check.js"
9- const versionCheck = require (' github-version-checker' )
9+ const versionCheck = require (' @ github-version-checker/core ' )
1010const options = {
1111 token: ' my-token' ,
1212 repo: ' github-version-checker' ,
@@ -16,12 +16,13 @@ const options = {
1616 fetchTags: true
1717}
1818
19- versionCheck (options, function (error , update ) {
19+ versionCheck (options, function (error , result ) {
2020 if (error) {
2121 console .error (error)
2222 process .exit (- 1 )
2323 }
2424
25+ const { update } = result
2526 if (update) {
2627 console .log (' An update is available! ' + update .name )
2728 console .log (' You are on version ' + options .currentVersion + ' !' )
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ There may be scenarios where you explicitly want to call the REST API.
55Set the ` token ` to ` false ` to accomplish this:
66
77``` js showLineNumbers title="src/util/version-check.js"
8- const versionCheck = require (' github-version-checker' )
8+ const versionCheck = require (' @ github-version-checker/core ' )
99const options = {
1010 // highlight-next-line
1111 token: false ,
@@ -15,7 +15,8 @@ const options = {
1515}
1616
1717versionCheck (options)
18- .then (function (update ) {
18+ .then (function (result ) {
19+ const { update } = result
1920 if (update) { // update is null if there is no update available, so check here
2021 console .log (' An update is available! ' + update .name )
2122 console .log (' You are on version ' + options .currentVersion + ' !' )
You can’t perform that action at this time.
0 commit comments