@@ -14,7 +14,7 @@ import { HttpsProxyAgent } from 'https-proxy-agent'
14
14
import { HttpProxyAgent } from 'http-proxy-agent'
15
15
import unzipper , { type Entry } from 'unzipper'
16
16
17
- import { BINARY_FILE , GECKODRIVER_RELEASES } from './constants.js'
17
+ import { BINARY_FILE , GECKODRIVER_CARGO_YAML } from './constants.js'
18
18
import { hasAccess , getDownloadUrl , retryFetch } from './utils.js'
19
19
20
20
const log = logger ( 'geckodriver' )
@@ -40,12 +40,13 @@ export async function download (
40
40
* get latest version of Geckodriver
41
41
*/
42
42
if ( ! geckodriverVersion ) {
43
- const res = await retryFetch ( GECKODRIVER_RELEASES , fetchOpts )
44
- const releases = await res . json ( ) as { name : string }
45
- geckodriverVersion = releases . name
46
- if ( ! geckodriverVersion ) {
47
- throw new Error ( `Couldn't find version name in releases : ${ JSON . stringify ( releases ) } ` )
43
+ const res = await retryFetch ( GECKODRIVER_CARGO_YAML , fetchOpts )
44
+ const toml = await res . text ( )
45
+ const version = toml . split ( '\n' ) . find ( ( l ) => l . startsWith ( 'version = ' ) )
46
+ if ( ! version ) {
47
+ throw new Error ( `Couldn't find version property in Cargo.toml file : ${ JSON . stringify ( toml ) } ` )
48
48
}
49
+ geckodriverVersion = version . split ( ' = ' ) . pop ( ) . slice ( 1 , - 1 )
49
50
log . info ( `Detected Geckodriver v${ geckodriverVersion } to be latest` )
50
51
}
51
52
0 commit comments