@@ -9,12 +9,13 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
9
9
10
10
const scripts = document . querySelectorAll ( 'script' ) ;
11
11
12
+ const allVersions = new Map < string , EditorVersionInfo > ( ) ;
13
+
12
14
for ( const script of scripts ) {
13
15
if ( script . textContent ) {
14
16
const matches = [ ...script . textContent . matchAll ( unity_version_regex ) ] ;
15
17
if ( matches . length > 0 ) {
16
- const uniqueVersions = new Set < string > ( ) ;
17
- return matches
18
+ const versions = matches
18
19
. filter ( ( match ) => {
19
20
// Filter out prerelease and unsupported versions
20
21
const [ _ , major , minor , patch , changeSet ] = match ;
@@ -23,8 +24,7 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
23
24
. map ( ( match ) => {
24
25
const [ _ , major , minor , patch , changeSet ] = match ;
25
26
const version = `${ major } .${ minor } .${ patch } ` ;
26
- if ( ! uniqueVersions . has ( version ) ) {
27
- uniqueVersions . add ( version ) ;
27
+ if ( ! allVersions . has ( version ) ) {
28
28
return {
29
29
version,
30
30
changeSet,
@@ -38,9 +38,17 @@ export const scrapeVersions = async (): Promise<EditorVersionInfo[]> => {
38
38
return null ;
39
39
} )
40
40
. filter ( ( version ) => version !== null ) as EditorVersionInfo [ ] ;
41
+
42
+ versions . forEach ( ( it ) => {
43
+ allVersions . set ( it . version , it ) ;
44
+ } ) ;
41
45
}
42
46
}
43
47
}
44
48
49
+ if ( allVersions . size > 0 ) {
50
+ return Array . from ( allVersions . values ( ) ) ;
51
+ }
52
+
45
53
throw new Error ( 'No Unity versions found!' ) ;
46
54
} ;
0 commit comments