# @exponent/spawn-async

> A Promise-based interface into processes created by child_process.spawn

Latest version **1.2.8** (published 2016-07-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @exponent/spawn-async
pnpm add @exponent/spawn-async
yarn add @exponent/spawn-async
bun add @exponent/spawn-async
```

## Health

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

Positive: no vulnerabilities; high maintenance score.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.8 |
| Published | 2016-07-28 |
| First published | 2015-05-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 72 |
| Author | support@getexponent.com |
| Maintainers | ccheever, exponent, ide |
| Keywords | spawn, child_process, async, promise, process |

## Links

- npm: https://www.npmjs.com/package/@exponent/spawn-async
- Repository: https://github.com/exponentjs/spawn-async
- Homepage: https://github.com/exponentjs/spawn-async#readme
- Issues: https://github.com/exponentjs/spawn-async/issues
- npm.io page: https://npm.io/package/@exponent/spawn-async

## Dependencies (1)

- [cross-spawn](https://npm.io/package/cross-spawn.md) ^4.0.0

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 1.2.8 (latest) — 2016-07-28
- 1.2.7 — 2016-07-28
- 1.2.6 — 2016-07-28
- 1.2.5 — 2016-07-27
- 1.2.4 — 2016-02-26
- 1.2.3 — 2015-12-10
- 1.2.2 — 2015-11-11
- 1.2.1 — 2015-11-05
- 1.2.0 — 2015-11-05
- 1.1.0 — 2015-05-26
- 1.0.1 — 2015-05-08
- 1.0.0 — 2015-05-08

## README

# spawn-async [![CircleCI](https://circleci.com/gh/exponentjs/spawn-async.svg?style=svg)](https://circleci.com/gh/exponentjs/spawn-async) [![Build Status](https://travis-ci.org/exponentjs/spawn-async.svg?branch=master)](https://travis-ci.org/exponentjs/spawn-async)

A cross-platform version of Node's `child_process.spawn` as an async function that returns a promise.

## Usage:
```js
import spawnAsync from '@exponent/spawn-async';

let resultPromise = spawnAsync('echo', ['hello', 'world'], { stdio: 'inherit' });
let spawnedChildProcess = resultPromise.child;
try {
  let {
    pid,
    output: [stdout, stderr],
    stdout,
    stderr,
    status,
    signal,
  } = await resultPromise;
} catch (e) {
  console.error(e.stack);
  // The error object also has the same properties as the result object
}
```

## API

`spawnAsync` takes the same arguments as [`child_process.spawn`](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options).

It returns a promise whose result is an object with these properties:

- `pid`: the process ID of the spawned child process
- `output`: an array with stdout and stderr's output
- `stdout`: a string of what the child process wrote to stdout
- `stderr`: a string of what the child process wrote to stderr
- `status`: the exit code of the child process
- `signal`: the signal (ex: `SIGTERM`) used to stop the child process if it did not exit on its own

If there's an error running the child process or it exits with a non-zero status code, `spawnAsync` rejects the returned promise. The Error object also has the properties listed above.

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