File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -53,9 +53,9 @@ cli.command('list', 'List changesets')
5353 . option ( '--latest-patch' , 'Output only the latest Unity patch versions' )
5454 . action ( options => ( async ( ) => {
5555 var results = options . all
56- ? ( await scrapeArchivedChangesets ( ) ) . concat ( await scrapeBetaChangesets ( ) )
56+ ? ( await scrapeArchivedChangesets ( ) ) . concat ( await scrapeBetaChangesets ( options . latestPatch ) )
5757 : options . beta
58- ? await scrapeBetaChangesets ( )
58+ ? await scrapeBetaChangesets ( options . latestPatch )
5959 : await scrapeArchivedChangesets ( ) ;
6060
6161 // Filter by min/max.
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export const scrapeArchivedChangesets = async (): Promise<UnityChangeset[]> => {
4949 . map ( href => UnityChangeset . createFromHref ( href ) ) ;
5050} ;
5151
52- export const scrapeBetaChangesets = async ( ) : Promise < UnityChangeset [ ] > => {
52+ export const scrapeBetaChangesets = async ( onlyLatestPatch : boolean = false ) : Promise < UnityChangeset [ ] > => {
5353 const document = await getDocumentFromUrl ( UNITY_BETA_URL ) ;
5454
5555 const betas = new Set < string > ( ) ;
@@ -60,12 +60,15 @@ export const scrapeBetaChangesets = async (): Promise<UnityChangeset[]> => {
6060
6161 const downloads = new Set < string > ( ) ;
6262 for ( const beta of betas ) {
63+ // onlyLatestPatch: Take only first.
64+ const takeCount = onlyLatestPatch ? 1 : undefined ;
6365 // [beta page] e.g. 'https://unity3d.com/beta/2020.2b'
6466 const betaPage = await getDocumentFromUrl ( `https://unity3d.com${ beta } ` ) ;
6567 Array . from ( betaPage . querySelectorAll ( 'a[href]' ) )
6668 . map ( ( a ) => a . getAttribute ( 'href' ) as string )
6769 // [filter] e.g. '/unity/beta/2020.2.0b13'
6870 . filter ( ( href ) => / ^ \/ u n i t y \/ ( a l p h a | b e t a ) \/ \d { 4 } \. \d + \. \d + ( a | b ) \d + $ / . test ( href ) )
71+ . slice ( 0 , takeCount )
6972 . forEach ( ( href ) => downloads . add ( href ) ) ;
7073 }
7174
You can’t perform that action at this time.
0 commit comments