MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / processWithStreamError

Function processWithStreamError

packages/agent-core/test/tools/bash.test.ts:186–219  ·  view source on GitHub ↗
(options: {
  readonly stdoutError?: Error;
  readonly stderrError?: Error;
  readonly exitCode?: number;
} = {})

Source from the content-addressed store, hash-verified

184}
185
186function processWithStreamError(options: {
187 readonly stdoutError?: Error;
188 readonly stderrError?: Error;
189 readonly exitCode?: number;
190} = {}): KaosProcess {
191 const exitCode = options.exitCode ?? 0;
192 const stdout = new PassThrough();
193 const stderr = new PassThrough();
194 const waitPromise = new Promise<number>((resolve) => {
195 setTimeout(() => {
196 if (options.stdoutError !== undefined) {
197 stdout.emit('error', options.stdoutError);
198 } else {
199 stdout.end();
200 }
201 if (options.stderrError !== undefined) {
202 stderr.emit('error', options.stderrError);
203 } else {
204 stderr.end();
205 }
206 resolve(exitCode);
207 }, 1);
208 });
209 return {
210 stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable,
211 stdout,
212 stderr,
213 pid: 128,
214 exitCode,
215 wait: vi.fn(async () => waitPromise),
216 kill: vi.fn(async () => {}),
217 dispose: vi.fn(async () => {}),
218 };
219}
220
221function processWithOpenStreamsThatExitOnKill(): KaosProcess {
222 let currentExitCode: number | null = null;

Callers 1

bash.test.tsFile · 0.85

Calls 3

resolveFunction · 0.50
emitMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected