(url: string, signal?: AbortSignal)
| 5 | import { type Entry, fromBuffer as yauzlFromBuffer } from 'yauzl'; |
| 6 | |
| 7 | export async function downloadZip(url: string, signal?: AbortSignal): Promise<Buffer> { |
| 8 | const controller = new AbortController(); |
| 9 | const timeoutHandle = setTimeout(() => { |
| 10 | controller.abort(); |
| 11 | }, 5 * 60 * 1000); |
| 12 | try { |
| 13 | const resp = await fetch(url, { signal: signal ?? controller.signal }); |
| 14 | if (!resp.ok) { |
| 15 | throw new Error(`Failed to download zip: HTTP ${resp.status} ${resp.statusText}`); |
| 16 | } |
| 17 | return Buffer.from(await resp.arrayBuffer()); |
| 18 | } finally { |
| 19 | clearTimeout(timeoutHandle); |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | export async function extractZip(buffer: Buffer, destDir: string): Promise<string> { |
| 24 | await mkdir(destDir, { recursive: true }); |
no test coverage detected