This PR improves some details when iterating over promise.stdout or promise.stderr.
Users are expected to do for await (const line of nanoSpawn(...).stdout), i.e. are not likely to await the subprocess promise. Therefore, when the for await loop stops due to break or an exception, the loop must await the subprocess promise. Otherwise, if the subprocess fails, it will result in an unhandled rejected promise. Note: this is also what Execa is doing.
Also, when the for await loop stops due to break, the subprocess stdout/stderr stream should not be destroyed, since the break might not indicate any problem nor failure.
Finally, this PR improves the related tests, and adds more of them.
This PR improves some details when iterating over
promise.stdout
orpromise.stderr
.Users are expected to do
for await (const line of nanoSpawn(...).stdout)
, i.e. are not likely toawait
the subprocess promise. Therefore, when thefor await
loop stops due tobreak
or an exception, the loop mustawait
the subprocess promise. Otherwise, if the subprocess fails, it will result in an unhandled rejected promise. Note: this is also what Execa is doing.Also, when the
for await
loop stops due tobreak
, the subprocessstdout
/stderr
stream should not be destroyed, since thebreak
might not indicate any problem nor failure.Finally, this PR improves the related tests, and adds more of them.