spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / tests / fixtures / backend-of / recording-backend-host-of.ts
27 lines · 791 BRaw
1import type { ProcessRunResult } from 'claude-code'
2
3import Scripted from '../scripted'
4import { backendHostOf } from './backend-host-of.js'
5import type { RecordingBackendHost } from './recording-backend-host.js'
6
7/**
8 * A backend host whose runner answers from a script and notes each program
9 * it was asked to run.
10 *
11 * @param script git's answers by subcommand
12 * @returns the host and the programs it ran, in order
13 */
14export function recordingBackendHostOf(
15 script: Readonly<Record<string, ProcessRunResult>>,
16): RecordingBackendHost {
17 const programs: (string | undefined)[] = []
18 const scripted = Scripted.scriptedGitOf(script)
19
20 const host = backendHostOf(([program, ...rest]) => {
21 programs.push(program)
22
23 return scripted.run(rest)
24 })
25
26 return { host, programs }
27}