File tree Expand file tree Collapse file tree 1 file changed +20
-9
lines changed
packages/hadron-build/commands Expand file tree Collapse file tree 1 file changed +20
-9
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const path = require('path');
1010const os = require ( 'os' ) ;
1111const { promises : fs } = require ( 'fs' ) ;
1212const { deepStrictEqual } = require ( 'assert' ) ;
13+ const semver = require ( 'semver' ) ;
1314const { Octokit } = require ( '@octokit/rest' ) ;
1415const { GithubRepo } = require ( '@mongodb-js/devtools-github-repo' ) ;
1516const { diffString } = require ( 'json-diff' ) ;
@@ -253,7 +254,7 @@ async function getLatestRelease(channel = 'stable') {
253254 auth : process . env . GITHUB_TOKEN ,
254255 } ) ;
255256
256- const page = 1 ;
257+ let page = 1 ;
257258
258259 // eslint-disable-next-line no-constant-condition
259260 while ( true ) {
@@ -279,14 +280,24 @@ async function getLatestRelease(channel = 'stable') {
279280 return null ;
280281 }
281282
282- const latestRelease = releases . find ( ( release ) => {
283- return (
284- ! release . draft &&
285- ( channel === 'beta'
286- ? isBeta ( release . tag_name )
287- : isStable ( release . tag_name ) )
288- ) ;
289- } ) ;
283+ const latestRelease = releases
284+ . sort ( ( a , b ) => {
285+ if ( semver . lt ( a . tag_name , b . tag_name ) ) {
286+ return 1 ;
287+ }
288+ if ( semver . gt ( a . tag_name , b . tag_name ) ) {
289+ return - 1 ;
290+ }
291+ return 0 ;
292+ } )
293+ . find ( ( release ) => {
294+ return (
295+ ! release . draft &&
296+ ( channel === 'beta'
297+ ? isBeta ( release . tag_name )
298+ : isStable ( release . tag_name ) )
299+ ) ;
300+ } ) ;
290301
291302 if ( latestRelease ) {
292303 return latestRelease ;
You can’t perform that action at this time.
0 commit comments