Skip to content

Commit c84c197

Browse files
committed
fix: add support for .zip files in binary download
1 parent c78ecb0 commit c84c197

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@
4444
"@commitlint/cli": "19.5.0",
4545
"@commitlint/config-conventional": "19.5.0",
4646
"@octokit/rest": "21.0.2",
47+
"@types/adm-zip": "0.5.7",
4748
"@types/node": "22.6.1",
4849
"@types/proxy-from-env": "1.0.4",
4950
"@typescript-eslint/eslint-plugin": "8.7.0",
5051
"@typescript-eslint/parser": "8.7.0",
5152
"@vercel/ncc": "0.38.2",
53+
"adm-zip": "0.5.16",
5254
"eslint": "8.57.1",
5355
"prettier": "3.3.3",
5456
"proxy": "2.2.0",

src/release.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { fetch, ProxyAgent } from "undici"
77
import type { RequestInit } from "undici"
88
import { extract } from "tar"
99
import tmp from "tmp-promise"
10+
import admzip from "adm-zip"
1011
import { COMBINED_PATH, NAME } from "./constants"
1112

1213
const 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

Comments
 (0)