waitFor waits until gh exits, the context ends or ready returns true. It reports whether gh exited, storing cmd.Wait's error in waitErr.
(ctx context.Context, exited <-chan error, waitErr *error, ready func() bool)
| 105 | // waitFor waits until gh exits, the context ends or ready returns true. It |
| 106 | // reports whether gh exited, storing cmd.Wait's error in waitErr. |
| 107 | func waitFor(ctx context.Context, exited <-chan error, waitErr *error, ready func() bool) bool { |
| 108 | tick := time.NewTicker(20 * time.Millisecond) |
| 109 | defer tick.Stop() |
| 110 | for { |
| 111 | select { |
| 112 | case err := <-exited: |
| 113 | *waitErr = err |
| 114 | return true |
| 115 | case <-ctx.Done(): |
| 116 | *waitErr = <-exited |
| 117 | return true |
| 118 | case <-tick.C: |
| 119 | if ready() { |
| 120 | return false |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | // screenText is the terminal's screen as text, without trailing spaces or |
| 127 | // blank lines at the bottom. |