MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / childProcessToPromise

Function childProcessToPromise

sdk/src/run-state.ts:235–260  ·  view source on GitHub ↗

* Helper to convert ChildProcess to Promise with stdout/stderr

(
  proc: ReturnType<CodebuffSpawn>,
)

Source from the content-addressed store, hash-verified

233 * Helper to convert ChildProcess to Promise with stdout/stderr
234 */
235function childProcessToPromise(
236 proc: ReturnType<CodebuffSpawn>,
237): Promise<{ stdout: string; stderr: string }> {
238 return new Promise((resolve, reject) => {
239 let stdout = ''
240 let stderr = ''
241
242 proc.stdout?.on('data', (data: Buffer) => {
243 stdout += data.toString()
244 })
245
246 proc.stderr?.on('data', (data: Buffer) => {
247 stderr += data.toString()
248 })
249
250 proc.on('close', (code: number | null) => {
251 if (code === 0) {
252 resolve({ stdout, stderr })
253 } else {
254 reject(new Error(`Command exited with code ${code}`))
255 }
256 })
257
258 proc.on('error', reject)
259 })
260}
261
262/**
263 * Retrieves git changes for the project using the provided spawn function

Callers 1

getGitChangesFunction · 0.85

Calls 2

resolveFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected