(
ghArgs: string[],
options: GhRetryOptions | number = {},
)
| 167 | } |
| 168 | |
| 169 | export async function ghTextWithRetryAsync( |
| 170 | ghArgs: string[], |
| 171 | options: GhRetryOptions | number = {}, |
| 172 | ): Promise<string> { |
| 173 | const resolved = resolveRetryOptions(options); |
| 174 | const attempts = Math.max(1, resolved.attempts ?? 6); |
| 175 | let lastError: unknown; |
| 176 | for (let attempt = 1; attempt <= attempts; attempt += 1) { |
| 177 | try { |
| 178 | return await ghTextAsync(ghArgs, resolved); |
| 179 | } catch (error) { |
| 180 | lastError = error; |
| 181 | if (attempt >= attempts || !shouldRetryGh(error)) throw error; |
| 182 | await sleepAsync(Math.min(1000 * attempt, 5000)); |
| 183 | } |
| 184 | } |
| 185 | throw lastError instanceof Error ? lastError : new Error(String(lastError)); |
| 186 | } |
| 187 | |
| 188 | export async function ghTextAsync(ghArgs: string[], options: GhRunOptions = {}): Promise<string> { |
| 189 | if (options.input !== undefined) return ghText(ghArgs, options); |
no test coverage detected