MCPcopy Create free account
hub / github.com/cli/cli / waitFor

Function waitFor

script/ghmock/terminal.go:107–124  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
107func 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.

Callers 1

runInTerminalFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected