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

Function processWithOutput

packages/agent-core/test/tools/bash.test.ts:30–55  ·  view source on GitHub ↗
(
  options: {
  readonly stdout?: string | Buffer;
  readonly stderr?: string | Buffer;
  readonly exitCode?: number | null;
  readonly wait?: () => Promise<number>;
  readonly kill?: (signal?: NodeJS.Signals) => Promise<void>;
  } = {},
)

Source from the content-addressed store, hash-verified

28};
29
30function processWithOutput(
31 options: {
32 readonly stdout?: string | Buffer;
33 readonly stderr?: string | Buffer;
34 readonly exitCode?: number | null;
35 readonly wait?: () => Promise<number>;
36 readonly kill?: (signal?: NodeJS.Signals) => Promise<void>;
37 } = {},
38): KaosProcess {
39 const exitCode = options.exitCode ?? 0;
40 const stdout = Readable.from(options.stdout === undefined ? [] : [options.stdout]);
41 const stderr = Readable.from(options.stderr === undefined ? [] : [options.stderr]);
42 return {
43 stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable,
44 stdout,
45 stderr,
46 pid: 123,
47 exitCode,
48 wait: vi.fn(options.wait ?? (async () => exitCode)),
49 kill: vi.fn(options.kill ?? (async () => {})),
50 dispose: vi.fn(async () => {
51 stdout.destroy();
52 stderr.destroy();
53 }),
54 };
55}
56
57function processWithInterleavedOutput(
58 events: ReadonlyArray<{

Callers 1

bash.test.tsFile · 0.70

Calls 1

destroyMethod · 0.80

Tested by

no test coverage detected