MCPcopy Create free account
hub / github.com/anus-dev/ANUS / onClose

Method onClose

packages/core/src/tools/grep.ts:423–441  ·  view source on GitHub ↗
(code: number | null)

Source from the content-addressed store, hash-verified

421 reject(new Error(`Failed to start system grep: ${err.message}`));
422 };
423 const onClose = (code: number | null) => {
424 const stdoutData = Buffer.concat(stdoutChunks).toString('utf8');
425 const stderrData = Buffer.concat(stderrChunks)
426 .toString('utf8')
427 .trim();
428 cleanup();
429 if (code === 0) resolve(stdoutData);
430 else if (code === 1)
431 resolve(''); // No matches
432 else {
433 if (stderrData)
434 reject(
435 new Error(
436 `System grep exited with code ${code}: ${stderrData}`,
437 ),
438 );
439 else resolve(''); // Exit code > 1 but no stderr, likely just suppressed errors
440 }
441 };
442
443 const cleanup = () => {
444 child.stdout.removeListener('data', onData);

Callers

nothing calls this directly

Calls 1

cleanupFunction · 0.50

Tested by

no test coverage detected