Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

child-process-ext

medikoo6.4mISC3.0.2

Extensions to Node.js child_process module

child_process, node, spawn

readme

Build status Tests coverage npm version

child-process-ext

Node.js child_process extensions

Installation

npm install child-process-ext

API

spawn(command[, args[, options]])

Cross system compliant spawn (backed by cross-spawn).

Works exactly same way as node's spawn with difference that promise is returned that resolves once process exits.

Following properties are exposed on return promise:

  • child - child process
  • stdout - stdout stream (decorated so it can also be used as promise)
  • stderr - stderr stream (decorated so it can also be used as promise)
  • std - Merged stdout & stderr stream (decorated so it can also be used as promise)
  • stdoutBuffer - Buffer that exposes so far written stdout
  • stderrBuffer - Buffer that exposes so far written stderrr
  • stdBuffer - Buffer that exposes so far written std

Promise resolves with object with three properties:

  • code - Exit code of a child proces
  • signal - Signal that terminated the process
  • stdoutBuffer - Buffer containing gathered stdout content
  • stderrBuffer - Buffer containing gathered stderr content
  • stdBuffer - Buffer containing gathered stderr content

If process exits with non zero code, then promise is rejected with an error exposing same properties as above

Non standard options
split bool (default: false)

Whether stdout data should be split by lines. If set to true, then stdout and stderr on promise expose mappers of original stdout and stderr that emit each line with distinct data event

shouldCloseStdin bool (default: false)

Whether stdin should be closed. Applicable for spawned processes where stdin is set to other than 'inherit' mode, and underlying processes is reading from stdin. Not providing any stdin output, may produce stall if process logic waits for an input. See: get-stdin#13 for more information

Tests

npm test

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

3.0.2 (2023-08-22)

Bug Fixes

  • Fix handling of just stderr being observable (cf390ff)

3.0.1 (2023-06-27)

Maintenance Improvements

  • Setup .npmignore rules (do not package dev files for npm package) (34184c1)

3.0.0 (2023-06-27)

⚠ BREAKING CHANGES

  • Drop support for Node.js versions lower than v8

Maintenance Improvements

  • Upgrade cross-spawn to v7 (1293c06)

2.1.1 (2020-04-05)

Bug Fixes

2.1.0 (2019-09-03)

Features

  • Configure debug logging (deb3ea1)
  • Expose std & stdBuffer properties (merged std output) (dabf7ca)
  • Improve exit error message (f52dfd9)
  • Introduce shouldCloseStdin option (ecddc13)

Tests

2.0.0 (2019-01-18)

Features

  • decorate std streams with promise behavior (bbf5dc1)
  • improve split handling (3a73750)

BREAKING CHANGES

  • Trailing non-empty line is now emittted

1.0.0 (2019-01-11)

Bug Fixes

  • expose programmer errors as promise rejections (25db17b)
  • windows requires double quotes (69f67f5)

Features

  • "split" option (1b31933)
  • expose current std buffers on promise (9541e99)
  • expose std buffers at better names (e4e0962)
  • expose std streams directly on promise (a2751c2)
  • improve arguments handling (41bb8e9)