MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/unstable/process/ChildProcessSpawner.ts:223–244  ·  view source on GitHub ↗
(spawn: ChildProcessSpawner["Service"]["spawn"])

Source from the content-addressed store, hash-verified

221 * @since 4.0.0
222 */
223export const make = (spawn: ChildProcessSpawner["Service"]["spawn"]): ChildProcessSpawner["Service"] => {
224 const streamString: ChildProcessSpawner["Service"]["streamLines"] = (command, options) =>
225 spawn(command).pipe(
226 Effect.map((handle) =>
227 Stream.decodeText(
228 options?.includeStderr === true ? handle.all : handle.stdout
229 )
230 ),
231 Stream.unwrap
232 )
233 const streamLines: ChildProcessSpawner["Service"]["streamLines"] = (command, options) =>
234 Stream.splitLines(streamString(command, options))
235
236 return ChildProcessSpawner.of({
237 spawn,
238 exitCode: (command) => Effect.scoped(Effect.flatMap(spawn(command), (handle) => handle.exitCode)),
239 streamString,
240 streamLines,
241 lines: (command, options) => Stream.runCollect(streamLines(command, options)),
242 string: (command, options) => Stream.mkString(streamString(command, options))
243 })
244}
245
246/**
247 * Service tag for child process spawning.

Callers

nothing calls this directly

Calls 4

streamLinesFunction · 0.85
streamStringFunction · 0.85
ofMethod · 0.65
spawnFunction · 0.50

Tested by

no test coverage detected