(command: ChildProcess.Command)
| 51 | } |
| 52 | |
| 53 | const flatten = (command: ChildProcess.Command) => { |
| 54 | const commands: Array<ChildProcess.StandardCommand> = [] |
| 55 | const opts: Array<ChildProcess.PipeOptions> = [] |
| 56 | |
| 57 | const walk = (cmd: ChildProcess.Command): void => { |
| 58 | switch (cmd._tag) { |
| 59 | case "StandardCommand": |
| 60 | commands.push(cmd) |
| 61 | return |
| 62 | case "PipedCommand": |
| 63 | walk(cmd.left) |
| 64 | opts.push(cmd.options) |
| 65 | walk(cmd.right) |
| 66 | return |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | walk(command) |
| 71 | if (commands.length === 0) throw new Error("flatten produced empty commands array") |
| 72 | const [head, ...tail] = commands |
| 73 | return { |
| 74 | commands: [head, ...tail] as Arr.NonEmptyReadonlyArray<ChildProcess.StandardCommand>, |
| 75 | opts, |
| 76 | } |
| 77 | } |
| 78 | |
| 79 | const toPlatformError = ( |
| 80 | method: string, |
no test coverage detected