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

Function pendingProcess

packages/agent-core/test/tools/bash.test.ts:97–132  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95}
96
97function pendingProcess(): {
98 readonly proc: KaosProcess;
99 readonly finish: (exitCode?: number) => void;
100} {
101 const stdout = new PassThrough();
102 const stderr = new PassThrough();
103 let resolveWait: (exitCode: number) => void = () => {};
104 let currentExitCode: number | null = null;
105 const waitPromise = new Promise<number>((resolve) => {
106 resolveWait = resolve;
107 });
108 const finish = (exitCode = 0): void => {
109 if (currentExitCode !== null) return;
110 currentExitCode = exitCode;
111 stdout.end();
112 stderr.end();
113 resolveWait(exitCode);
114 };
115 return {
116 proc: {
117 stdin: { end: vi.fn(), write: vi.fn() } as unknown as Writable,
118 stdout,
119 stderr,
120 pid: 125,
121 get exitCode(): number | null {
122 return currentExitCode;
123 },
124 wait: vi.fn(async () => waitPromise),
125 kill: vi.fn(async () => {
126 finish(143);
127 }) as KaosProcess['kill'],
128 dispose: vi.fn(async () => {}),
129 },
130 finish,
131 };
132}
133
134function processWithVisibleExitBeforeWait(exitCode = 0): {
135 proc: KaosProcess;

Callers 1

bash.test.tsFile · 0.70

Calls 1

finishFunction · 0.70

Tested by

no test coverage detected