(ghArgs: string[], options: GhRetryOptions | number = {})
| 151 | } |
| 152 | |
| 153 | export function ghTextWithRetry(ghArgs: string[], options: GhRetryOptions | number = {}): string { |
| 154 | const resolved = resolveRetryOptions(options); |
| 155 | const attempts = Math.max(1, resolved.attempts ?? 6); |
| 156 | let lastError: unknown; |
| 157 | for (let attempt = 1; attempt <= attempts; attempt += 1) { |
| 158 | try { |
| 159 | return ghText(ghArgs, resolved); |
| 160 | } catch (error) { |
| 161 | lastError = error; |
| 162 | if (attempt >= attempts || !shouldRetryGh(error)) throw error; |
| 163 | sleepMs(Math.min(1000 * attempt, 5000)); |
| 164 | } |
| 165 | } |
| 166 | throw lastError instanceof Error ? lastError : new Error(String(lastError)); |
| 167 | } |
| 168 | |
| 169 | export async function ghTextWithRetryAsync( |
| 170 | ghArgs: string[], |
no test coverage detected