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

Function flattenCommand

packages/platform/deno/src/DenoChildProcessSpawner.ts:418–439  ·  view source on GitHub ↗
(command: ChildProcess.Command)

Source from the content-addressed store, hash-verified

416 * @since 4.0.0
417 */
418export const flattenCommand = (command: ChildProcess.Command): FlattenedPipeline => {
419 const commands: Array<ChildProcess.StandardCommand> = []
420 const pipeOptions: Array<ChildProcess.PipeOptions> = []
421
422 const flatten = (command: ChildProcess.Command): void => {
423 switch (command._tag) {
424 case "StandardCommand":
425 commands.push(command)
426 break
427 case "PipedCommand":
428 flatten(command.left)
429 pipeOptions.push(command.options)
430 flatten(command.right)
431 break
432 }
433 }
434 flatten(command)
435
436 const [first, ...rest] = commands
437 if (first === undefined) throw new Error("flattenCommand produced empty commands array")
438 return { commands: [first, ...rest], pipeOptions }
439}

Callers 2

commandStringFunction · 0.70

Calls 1

flattenFunction · 0.70

Tested by

no test coverage detected