Repository navigation
Breaking
- Require Node.js 22 0daccc8
- Remove
{string: '...'}from thestdinandstdiooptions in favor of the newinputoption (#112) 3c6e154- Passing
{string: '...'}now throws an error that points to theinputoption. See the migration guide below.
- Passing
New
- Add
inputoption (#112) 3c6e154await spawn('gh', ['auth', 'login', '--with-token'], {input: token})
Fixes
- Fix arguments of Windows batch files that read them with
%~1(#117) 1a47181- Arguments were caret-escaped twice, so batch files like Maven's
mvn.cmdor the Gradle launchers of the Android SDK (sdkmanager.bat) received leftover^characters. Arguments are now quoted the same way Rust and Execa do it, which works whether the batch file reads its arguments (%1,%~1) or forwards them (%*). See the Windows support section for the remaining limitations of batch files.
- Arguments were caret-escaped twice, so batch files like Maven's
- Fix premature rejection of canceled subprocesses (#118) a45d011
- Cancellation with the
signaloption now waits for the subprocess to exit and its streams to close before it rejects. This makes cleanup afterawaitsafe, and the error includes the final output. If the subprocess ignores the termination signal, the promise stays pending.
- Cancellation with the
- Fix subprocess failures that were never reported 396e83a
- An error in a stdio stream of a long-running subprocess now rejects right away, instead of waiting for the subprocess to exit.
- Iteration no longer hangs when the subprocess fails while its streams are still open.
- Iterating the subprocess (both
stdoutandstderr) no longer loses lines when one stream fails.
- Fix
.pipe()errors, warnings, andSIGPIPEhandling c50291f- When the destination stops reading early, like
head, the source is terminated withSIGPIPE. The pipeline now uses the destination's result, like a shell does, instead of rejecting. The source's error is still available inpipedFrom. - Invalid
stdin/stdoutoptions now reject with aSubprocessError. The previous messages named the wrong subprocess. - Piping one source to many destinations no longer prints a
MaxListenersExceededWarning.
- When the destination stops reading early, like
- Fix running
nodewhen the current process uses--inspect-port <port>or--inspect-publish-uid <value>d6735f0- The value was passed to the subprocess and run as a script.
- Fix
node.exeandNODEbeing replaced with the current Node.js binary on macOS and Linux d6735f0 5087b0a- Those names only refer to the
nodebinary on Windows.
- Those names only refer to the
- Fix a hang when iteration stops early (
break) while the subprocess still writes a lot of output 5087b0a - Fix memory growth when iterating a subprocess that writes only to one of
stdoutorstderr5087b0a - Fix Windows executable detection using stale results after a program is installed or removed 5087b0a
- Relative
PATHentries are now also resolved from the subprocess'scwd, like Node.js does.
- Relative
- Escape control characters, like newlines, in
result.command, so one argument cannot span several log lines 5087b0a
Migration guide
{string: '...'} to input
-await spawn('cat', {stdin: {string: 'unicorn'}});
+await spawn('cat', {input: 'unicorn'});The input option cannot be combined with the stdin or stdio options. If you passed {string: '...'} as the first item of stdio, use input with the stdout and stderr options instead:
-await spawn('cat', {stdio: [{string: 'unicorn'}, 'inherit', 'pipe']});
+await spawn('cat', {input: 'unicorn', stdout: 'inherit'});