(url)
| 172 | } |
| 173 | |
| 174 | async function downloadUrlToBufferWithFallback(url) { |
| 175 | let firstError |
| 176 | try { |
| 177 | return await downloadUrlToBuffer(url) |
| 178 | } catch (e) { |
| 179 | firstError = e |
| 180 | } |
| 181 | |
| 182 | const tmpRoot = path.join( |
| 183 | os.tmpdir(), |
| 184 | `ripgrep-dl-${process.pid}-${Date.now()}`, |
| 185 | ) |
| 186 | const tmpFile = path.join(tmpRoot, 'archive') |
| 187 | mkdirSync(tmpRoot, { recursive: true }) |
| 188 | try { |
| 189 | if (process.platform === 'win32' && tryPowerShellDownload(url, tmpFile)) { |
| 190 | return readFileSync(tmpFile) |
| 191 | } |
| 192 | if (tryCurlDownload(url, tmpFile)) { |
| 193 | return readFileSync(tmpFile) |
| 194 | } |
| 195 | } finally { |
| 196 | rmSync(tmpRoot, { recursive: true, force: true }) |
| 197 | } |
| 198 | |
| 199 | throw firstError |
| 200 | } |
| 201 | |
| 202 | // --- Extract --- |
| 203 |
no test coverage detected