# @figliolia/child-process

> A wrapper around the node.js spawn function providing a promise and graceful exiting

Latest version **1.0.4** (published 2024-04-13) · 0 weekly downloads

## Install

```sh
npm install @figliolia/child-process
pnpm add @figliolia/child-process
yarn add @figliolia/child-process
bun add @figliolia/child-process
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2024-04-13 |
| First published | 2023-12-26 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | alexfigliolia |
| Keywords | node, node.js, child process |

## Links

- npm: https://www.npmjs.com/package/@figliolia/child-process
- npm.io page: https://npm.io/package/@figliolia/child-process

## 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

- 1.0.4 (latest) — 2024-04-13
- 1.0.3 — 2024-01-13
- 1.0.2 — 2023-12-26
- 1.0.1 — 2023-12-26
- 1.0.0 — 2023-12-26

## README

# Child Process
A small wrapper around the Node.js `ChildProcess.spawn` function that provides access to not only the child process, but a wrapping promise to use in your JavaScript logic.

# Getting Started

## Installation
```bash
npm install --save @figliolia/child-process
# or
yarn add @figliolia/child-process
```

### Basic Usage

```typescript
import { ChildProcess } from "@figliolia/child-process";

const CP = new ChildProcess(
  "some shell command"
);

// Await the completion of your command
await CP.handler;

// Use the raw child process in your code
CP.process.on("something", () => {});

// If you do not need access to the underlying child process, 
// but instead wish to have just a promise with stdio access
const { stdout, stderr } = await ChildProcess.execute("your command");
```

### Advanced Usage
It's fairly common to require the management of multiple sub-process when building complex applications such as development environments, CI's, and more.

This library provides a means for handling multiple child processes as well as binding to kill exit signals that may cause an underlying application to fail.

```typescript
import { ChildProcess } from "@figliolia/child-process";

class MyApplication {

	public static run() {
		const shells = this.bootStuffUp();
		// Kill each shell if the parent process receives
		// a kill signal or uncaught exception
		ChildProcess.bindExits(shells);
		// Await the completion of all commands
		return Promise.all(shells.map(CP => CP.handler));
	}

	private static bootStuffUp() {
		return [
			new ChildProcess(
				"some shell command"
			),
			new ChildProcess(
				"another shell command"
			),
			new ChildProcess(
				"perhaps another shell command"
			),
		]
	}
}
```

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