(command: ChildProcess.Command)
| 416 | * @since 4.0.0 |
| 417 | */ |
| 418 | export 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 | } |
no test coverage detected