( fn: () => Promise<unknown> | unknown, )
| 321 | } |
| 322 | |
| 323 | export async function waitFor( |
| 324 | fn: () => Promise<unknown> | unknown, |
| 325 | ): Promise<void> { |
| 326 | let now = Date.now(); |
| 327 | const limit = now + 2000; |
| 328 | |
| 329 | while (now < limit) { |
| 330 | try { |
| 331 | if (await fn()) return; |
| 332 | } catch (err) { |
| 333 | if (now > limit) { |
| 334 | throw err; |
| 335 | } |
| 336 | } finally { |
| 337 | await new Promise((r) => setTimeout(r, 250)); |
| 338 | now = Date.now(); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | throw new Error(`Timed out`); |
| 343 | } |
| 344 | |
| 345 | export function getStdOutput( |
| 346 | out: Deno.CommandOutput, |
no test coverage detected