MCPcopy
hub / github.com/anomalyco/opencode / stdios

Function stdios

packages/core/src/cross-spawn-spawner.ts:148–166  ·  view source on GitHub ↗
(
    sin: ChildProcess.StdinConfig,
    sout: ChildProcess.StdoutConfig,
    serr: ChildProcess.StderrConfig,
    extra: ReadonlyArray<{ fd: number; config: ChildProcess.AdditionalFdConfig }>,
  )

Source from the content-addressed store, hash-verified

146 }
147
148 const stdios = (
149 sin: ChildProcess.StdinConfig,
150 sout: ChildProcess.StdoutConfig,
151 serr: ChildProcess.StderrConfig,
152 extra: ReadonlyArray<{ fd: number; config: ChildProcess.AdditionalFdConfig }>,
153 ): NodeChildProcess.StdioOptions => {
154 const pipe = (x: NodeChildProcess.IOType | undefined) =>
155 process.platform === "win32" && x === "pipe" ? "overlapped" : x
156 const arr: Array<NodeChildProcess.IOType | undefined> = [
157 pipe(input(sin.stream)),
158 pipe(output(sout.stream)),
159 pipe(output(serr.stream)),
160 ]
161 if (extra.length === 0) return arr as NodeChildProcess.StdioOptions
162 const max = extra.reduce((acc, x) => Math.max(acc, x.fd), 2)
163 for (let i = 3; i <= max; i++) arr[i] = "ignore"
164 for (const x of extra) arr[x.fd] = pipe("pipe")
165 return arr as NodeChildProcess.StdioOptions
166 }
167
168 const setupFds = Effect.fnUntraced(function* (
169 command: ChildProcess.StandardCommand,

Callers 1

Calls 3

pipeFunction · 0.85
inputFunction · 0.70
outputFunction · 0.70

Tested by

no test coverage detected