Skip to content

v3.0.0

Latest

Choose a tag to compare

@sindresorhus sindresorhus released this 14 Nov 19:56

Breaking

  • Require Node.js 22 0daccc8
  • Remove {string: '...'} from the stdin and stdio options in favor of the new input option (#112) 3c6e154
    • Passing {string: '...'} now throws an error that points to the input option. See the migration guide below.

New

  • Add input option (#112) 3c6e154
    • await 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.cmd or 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.
  • Fix premature rejection of canceled subprocesses (#118) a45d011
    • Cancellation with the signal option now waits for the subprocess to exit and its streams to close before it rejects. This makes cleanup after await safe, and the error includes the final output. If the subprocess ignores the termination signal, the promise stays pending.
  • 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 stdout and stderr) no longer loses lines when one stream fails.
  • Fix .pipe() errors, warnings, and SIGPIPE handling c50291f
    • When the destination stops reading early, like head, the source is terminated with SIGPIPE. The pipeline now uses the destination's result, like a shell does, instead of rejecting. The source's error is still available in pipedFrom.
    • Invalid stdin/stdout options now reject with a SubprocessError. The previous messages named the wrong subprocess.
    • Piping one source to many destinations no longer prints a MaxListenersExceededWarning.
  • Fix running node when 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.exe and NODE being replaced with the current Node.js binary on macOS and Linux d6735f0 5087b0a
    • Those names only refer to the node binary on Windows.
  • 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 stdout or stderr 5087b0a
  • Fix Windows executable detection using stale results after a program is installed or removed 5087b0a
    • Relative PATH entries are now also resolved from the subprocess's cwd, like Node.js does.
  • 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'});

v2.1.0...v3.0.0