# child-process-ext

> Extensions to Node.js child_process module

Latest version **3.0.2** (published 2023-08-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install child-process-ext
pnpm add child-process-ext
yarn add child-process-ext
bun add child-process-ext
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2023-08-22 |
| First published | 2019-01-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.0 |
| Dependencies | 5 |
| Unpacked size | 13.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Mariusz Nowak |
| Maintainers | medikoo |
| Keywords | child_process, node, spawn |

## Links

- npm: https://www.npmjs.com/package/child-process-ext
- Repository: https://github.com/medikoo/child-process-ext
- Homepage: https://github.com/medikoo/child-process-ext#readme
- Issues: https://github.com/medikoo/child-process-ext/issues
- npm.io page: https://npm.io/package/child-process-ext

## Dependencies (5)

- [log](https://npm.io/package/log.md) ^6.3.1
- [split2](https://npm.io/package/split2.md) ^3.2.2
- [es5-ext](https://npm.io/package/es5-ext.md) ^0.10.62
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [stream-promise](https://npm.io/package/stream-promise.md) ^3.2.0

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 3.0.2 (latest) — 2023-08-22
- 3.0.1 — 2023-06-27
- 3.0.0 — 2023-06-27
- 2.1.1 — 2020-04-05
- 2.1.0 — 2019-09-03
- 2.0.0 — 2019-01-18
- 1.0.0 — 2019-01-11

## README

[![Build status][build-image]][build-url]
[![Tests coverage][cov-image]][cov-url]
[![npm version][npm-image]][npm-url]

# child-process-ext

## [Node.js `child_process`](https://nodejs.org/api/child_process..html) extensions

### Installation

```bash
npm install child-process-ext
```

### API

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

Cross system compliant [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) (backed by [`cross-spawn`](https://www.npmjs.com/package/cross-spawn)).

Works exactly same way as node's [`spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options) 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](https://github.com/sindresorhus/get-stdin/issues/13#issuecomment-279234249) for more information_

### Tests

```bash
npm test
```

[build-image]: https://github.com/medikoo/child-process-ext/workflows/Integrate/badge.svg
[build-url]: https://github.com/medikoo/child-process-ext/actions?query=workflow%3AIntegrate
[cov-image]: https://img.shields.io/codecov/c/github/medikoo/child-process-ext.svg
[cov-url]: https://codecov.io/gh/medikoo/child-process-ext
[npm-image]: https://img.shields.io/npm/v/child-process-ext.svg
[npm-url]: https://www.npmjs.com/package/child-process-ext

---
_Source: https://npm.io/package/child-process-ext · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
