(filePath: string, expected: string)
| 90 | } |
| 91 | |
| 92 | async function verifySha256(filePath: string, expected: string): Promise<void> { |
| 93 | const { createHash } = await import('crypto'); |
| 94 | const { readFileSync } = await import('fs'); |
| 95 | const actual = createHash('sha256').update(readFileSync(filePath)).digest('hex'); |
| 96 | if (actual !== expected) { |
| 97 | throw new CLIError( |
| 98 | `Checksum mismatch.\n expected: ${expected}\n actual: ${actual}`, |
| 99 | ExitCode.GENERAL, |
| 100 | ); |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | async function downloadFile(url: string, dest: string, onProgress?: (pct: number) => void): Promise<void> { |
| 105 | const res = await fetch(url, { signal: AbortSignal.timeout(120_000) }); |
no test coverage detected