# tools/core/runners/process.runner.ts

> 26 lines of code and 6 definitions.

Tree: Coordination tree
Language: typescript
Canonical: https://banes-lab.com/anatomy/coordination#file-coordination-tools-core-runners-process-runner-ts
Source text: https://banes-lab.com/assets/sources/source.af9d447ebfe6cef639a9d3cd8b0d6b9d0ad555a6f03cfae03503c561e249ea31.generated.txt

## Definitions

- `ProcessResult` (interface_declaration, line 3, exported)
- `runTool` (lexical_declaration, line 12, exported)
- `result` (lexical_declaration, line 19, exported)
- `launched` (lexical_declaration, line 25, exported)
- `output` (lexical_declaration, line 26, exported)
- `exitCode` (lexical_declaration, line 27, exported)

## Source

```typescript
import { spawnSync } from "node:child_process";

export interface ProcessResult {
    readonly step: string;
    readonly tool: string;
    readonly checks: string;
    readonly verdict: "fail" | "pass";
    readonly exitCode: number;
    readonly output: string;
}

export const runTool = function runTool(
    cwd: string,
    step: string,
    tool: string,
    checks: string,
    args: readonly string[],
): ProcessResult {
    const result = spawnSync(`${tool} ${args.join(" ")}`.trim(), {
        cwd,
        encoding: "utf8",
        shell: true,
    });

    const launched = result.error === undefined;
    const output = launched ? `${result.stdout}${result.stderr}`.trim() : String(result.error);
    const exitCode = launched ? (result.status ?? -1) : -1;

    return { checks, exitCode, output, step, tool, verdict: exitCode === 0 ? "pass" : "fail" };
};
```
