@@ -7,6 +7,7 @@ import { fetch, ProxyAgent } from "undici"
77import type { RequestInit } from "undici"
88import { extract } from "tar"
99import tmp from "tmp-promise"
10+ import admzip from "adm-zip"
1011import { COMBINED_PATH , NAME } from "./constants"
1112
1213const octokit = new Octokit ( { request : { fetch : proxiedFetch } } )
@@ -15,7 +16,10 @@ export async function findRelease(version: string) {
1516 const release = await getRelease ( version )
1617 const releasePrefix = getAssetPrefix ( )
1718 const matchedAsset = release . data . assets . find ( ( { name } ) => {
18- return name . startsWith ( releasePrefix ) && name . endsWith ( ".tar.gz" )
19+ return (
20+ name . startsWith ( releasePrefix ) &&
21+ ( name . endsWith ( ".tar.gz" ) || name . endsWith ( ".zip" ) )
22+ )
1923 } )
2024 if ( ! matchedAsset ) {
2125 throw new Error ( `The binary '${ releasePrefix } *' not found` )
@@ -27,7 +31,14 @@ export async function downloadBinary(url: string) {
2731 const response = await proxiedFetch ( url )
2832 const tmpfile = await tmp . file ( )
2933 await writeFile ( tmpfile . path , Buffer . from ( await response . arrayBuffer ( ) ) )
30- await extract ( { file : tmpfile . path , cwd : COMBINED_PATH , strict : true } )
34+
35+ if ( url . endsWith ( ".zip" ) ) {
36+ const zip = new admzip ( tmpfile . path )
37+ zip . extractAllTo ( COMBINED_PATH , true )
38+ } else {
39+ await extract ( { file : tmpfile . path , cwd : COMBINED_PATH , strict : true } )
40+ }
41+
3142 await tmpfile . cleanup ( )
3243}
3344
0 commit comments