dsherret / dax

Cross-platform shell tools for Deno and Node.js inspired by zx.
MIT License
1.05k stars 35 forks source link

Ability to pipe stdout/stderr of another command to stdin of another #79

Closed dsherret closed 1 year ago

dsherret commented 1 year ago

It should be possible to do something like:

const child = $`echo 1 && sleep 10 && echo 2`.stdout("piped").spawn();
await $`deno eval 'await Deno.stdin.readable.pipeTo(Deno.stdout.writable);'`.stdin(child.stdout());

I think probably the return value of spawn() should instead be a special kind of Promise that has methods like .stdout() and .stderr() on it.

I think it's ok that this is a little verbose since this isn't a common scenario.

dsherret commented 1 year ago

Implemented in #82 and a higher level pipe method implemented in https://github.com/dsherret/dax/pull/218