( url: string, destPath: string, asJson: boolean, )
| 717 | |
| 718 | // fallow-ignore-next-line complexity |
| 719 | async function streamVideo( |
| 720 | url: string, |
| 721 | destPath: string, |
| 722 | asJson: boolean, |
| 723 | ): Promise<{ bytes: number }> { |
| 724 | // `downloadToFile` already creates the parent directory and cleans |
| 725 | // up the partial file on error — no pre-mkdir needed here. |
| 726 | if (!asJson) { |
| 727 | console.log(""); |
| 728 | console.log(`${c.accent("◆")} Downloading to ${c.accent(destPath)}`); |
| 729 | } |
| 730 | try { |
| 731 | const result = await downloadToFile(url, destPath); |
| 732 | if (!asJson) { |
| 733 | console.log(c.dim(` ${formatBytes(result.bytes)} written`)); |
| 734 | } |
| 735 | return { bytes: result.bytes }; |
| 736 | } catch (err) { |
| 737 | const message = normalizeErrorMessage(err); |
| 738 | errorBox( |
| 739 | "Download failed", |
| 740 | message, |
| 741 | "The presigned URL is short-lived; re-fetch with `hyperframes cloud get`.", |
| 742 | ); |
| 743 | process.exit(1); |
| 744 | } |
| 745 | } |
no test coverage detected