MCPcopy Index your code
hub / github.com/continuedev/continue / waitForPattern

Function waitForPattern

extensions/cli/src/test-helpers/cli-helpers.ts:212–240  ·  view source on GitHub ↗
(
  proc: Subprocess,
  pattern: RegExp | string,
  timeout: number = 5000,
)

Source from the content-addressed store, hash-verified

210 * Waits for a pattern in the output
211 */
212export function waitForPattern(
213 proc: Subprocess,
214 pattern: RegExp | string,
215 timeout: number = 5000,
216): Promise<string> {
217 return new Promise((resolve, reject) => {
218 let output = "";
219 const timer = setTimeout(() => {
220 proc.kill();
221 reject(new Error(`Timeout waiting for pattern: ${pattern}`));
222 }, timeout);
223
224 const checkOutput = (data: string) => {
225 output += data;
226 const match =
227 typeof pattern === "string"
228 ? output.includes(pattern)
229 : pattern.test(output);
230
231 if (match) {
232 clearTimeout(timer);
233 resolve(output);
234 }
235 };
236
237 proc.stdout?.on("data", checkOutput);
238 proc.stderr?.on("data", checkOutput);
239 });
240}
241
242/**
243 * Simulates user input in interactive mode

Callers

nothing calls this directly

Calls 2

killMethod · 0.80
onMethod · 0.65

Tested by

no test coverage detected