This repository was archived by the owner on Dec 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +39
-5
lines changed
Expand file tree Collapse file tree 2 files changed +39
-5
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ const https = require('https');
33const github_graphql = require ( 'github-graphql-client' ) ;
44const semver = require ( 'semver' ) ;
55const query = require ( './query' ) ;
6+ const schemeMapper = require ( './scheme-mapper' ) ;
67const pkg = require ( '../package.json' ) ;
78
89/**
@@ -79,24 +80,32 @@ const rest = (options, callback) => {
7980 let version = null ;
8081 for ( let i = 0 ; i < json . length ; i ++ ) {
8182 version = json [ i ] ;
82- if ( semver . gt ( version . tag_name , options . currentVersion ) ) {
83+ if ( semver . gt ( version [ options . fetchTags ? 'name' : ' tag_name' ] , options . currentVersion ) ) {
8384 found = true ;
8485 break ;
8586 }
8687 }
8788
8889 if ( found ) {
89- callback ( null , version ) ;
90+ const mapped = schemeMapper [ options . fetchTags ? 'tag' : 'release' ] ( version ) ;
91+ console . log ( mapped ) ;
92+ callback ( null , mapped ) ;
9093 } else {
9194 callback ( null , null ) ;
9295 }
9396 } ) ;
9497 } ;
9598
9699 // build url
97- let apiUrl = `https://api.github.com/repos/${ options . owner } /${ options . repo } /releases` ;
98- if ( options . latestOnly ) {
99- apiUrl += '/latest' ;
100+ let apiUrl = `https://api.github.com/repos/${ options . owner } /${ options . repo } ` ;
101+ if ( options . fetchTags ) {
102+ apiUrl += '/tags' ;
103+ } else {
104+ apiUrl += '/releases' ;
105+
106+ if ( options . latestOnly ) {
107+ apiUrl += '/latest' ;
108+ }
100109 }
101110
102111 // define request options
Original file line number Diff line number Diff line change 1+ /**
2+ * Maps a response object into the form described here:
3+ * https://github.com/axelrindle/github-version-checker/wiki/API#releases
4+ */
5+ module . exports . release = obj => {
6+ return {
7+ name : obj . name ,
8+ tag : {
9+ name : obj . tag_name
10+ } ,
11+ isPrerelease : obj . prerelease ,
12+ publishedAt : obj . published_at ,
13+ url : obj . html_url
14+ }
15+ } ;
16+
17+ /**
18+ * Maps a response object into the form described here:
19+ * https://github.com/axelrindle/github-version-checker/wiki/API#tags
20+ */
21+ module . exports . tag = obj => {
22+ return {
23+ name : obj . name
24+ }
25+ } ;
You can’t perform that action at this time.
0 commit comments