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')
53
53
. option ( '--latest-patch' , 'Output only the latest Unity patch versions' )
54
54
. action ( options => ( async ( ) => {
55
55
var results = options . all
56
- ? ( await scrapeArchivedChangesets ( ) ) . concat ( await scrapeBetaChangesets ( ) )
56
+ ? ( await scrapeArchivedChangesets ( ) ) . concat ( await scrapeBetaChangesets ( options . latestPatch ) )
57
57
: options . beta
58
- ? await scrapeBetaChangesets ( )
58
+ ? await scrapeBetaChangesets ( options . latestPatch )
59
59
: await scrapeArchivedChangesets ( ) ;
60
60
61
61
// Filter by min/max.
Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export const scrapeArchivedChangesets = async (): Promise<UnityChangeset[]> => {
49
49
. map ( href => UnityChangeset . createFromHref ( href ) ) ;
50
50
} ;
51
51
52
- export const scrapeBetaChangesets = async ( ) : Promise < UnityChangeset [ ] > => {
52
+ export const scrapeBetaChangesets = async ( onlyLatestPatch : boolean = false ) : Promise < UnityChangeset [ ] > => {
53
53
const document = await getDocumentFromUrl ( UNITY_BETA_URL ) ;
54
54
55
55
const betas = new Set < string > ( ) ;
@@ -60,12 +60,15 @@ export const scrapeBetaChangesets = async (): Promise<UnityChangeset[]> => {
60
60
61
61
const downloads = new Set < string > ( ) ;
62
62
for ( const beta of betas ) {
63
+ // onlyLatestPatch: Take only first.
64
+ const takeCount = onlyLatestPatch ? 1 : undefined ;
63
65
// [beta page] e.g. 'https://unity3d.com/beta/2020.2b'
64
66
const betaPage = await getDocumentFromUrl ( `https://unity3d.com${ beta } ` ) ;
65
67
Array . from ( betaPage . querySelectorAll ( 'a[href]' ) )
66
68
. map ( ( a ) => a . getAttribute ( 'href' ) as string )
67
69
// [filter] e.g. '/unity/beta/2020.2.0b13'
68
70
. 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 )
69
72
. forEach ( ( href ) => downloads . add ( href ) ) ;
70
73
}
71
74
You can’t perform that action at this time.
0 commit comments