MCPcopy
hub / github.com/QwikDev/qwik / runCommandUntil

Function runCommandUntil

e2e/qwik-cli-e2e/utils/index.ts:99–132  ·  view source on GitHub ↗
(
  command: string,
  tmpDir: string,
  criteria: (output: string) => boolean
)

Source from the content-addressed store, hash-verified

97}
98
99export function runCommandUntil(
100 command: string,
101 tmpDir: string,
102 criteria: (output: string) => boolean
103): Promise<ChildProcess> {
104 const p = exec(command, {
105 cwd: tmpDir,
106 encoding: 'utf-8',
107 });
108 registerExecutedChildProcess(p);
109 return new Promise<ChildProcess>((res, rej) => {
110 let output = '';
111 let complete = false;
112
113 function checkCriteria(c: any) {
114 output += c.toString();
115 console.warn(output);
116 if (criteria(stripConsoleColors(output)) && !complete) {
117 complete = true;
118 res(p);
119 }
120 }
121
122 p.stdout?.on('data', checkCriteria);
123 p.stderr?.on('data', checkCriteria);
124 p.on('exit', (code) => {
125 if (!complete) {
126 rej(`Exited with ${code}`);
127 } else {
128 res(p);
129 }
130 });
131 });
132}
133
134function stripConsoleColors(log: string): string {
135 return log.replace(

Callers 1

serve.spec.tsFile · 0.90

Calls 2

onMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…