sindresorhus / nano-spawn

Tiny process execution for humans — a better child_process
MIT License
195 stars 4 forks source link

Refactor `.pipe()` logic #52

Closed ehmicky closed 2 weeks ago

ehmicky commented 2 weeks ago

Follow-up on #51.

This improves the .pipe() logic. That logic relies on recursion (each .pipe() calls a new nanoSpawn() ). This PR simplifies how that recursion works.

This removes 15 lines, worth ~350 bytes.

It also improves the error handling logic, to ensure that if any subprocess fails, the stdin of all subprocesses is ended. This prevents any hanging processes.