# await-spawn

> > `child_process.spawn()` wrapped in a `Promise` for doing async/await.

Latest version **4.0.2** (published 2021-04-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install await-spawn
pnpm add await-spawn
yarn add await-spawn
bun add await-spawn
```

## 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 | 4.0.2 |
| Published | 2021-04-16 |
| First published | 2017-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 1 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 40 |
| Author | Lars-Magnus Skog |
| Maintainers | ralphtheninja |
| Keywords | await, spawn, promise |

## Links

- npm: https://www.npmjs.com/package/await-spawn
- Repository: https://github.com/ralphtheninja/await-spawn
- Issues: https://github.com/ralphtheninja/await-spawn/issues
- npm.io page: https://npm.io/package/await-spawn

## Dependencies (1)

- [bl](https://npm.io/package/bl.md) ^4.0.3

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

- 4.0.2 (latest) — 2021-04-16
- 4.0.1 — 2020-09-05
- 4.0.0 — 2020-09-05
- 3.0.0 — 2019-08-23
- 2.1.2 — 2018-11-27
- 2.1.1 — 2018-05-07
- 2.1.0 — 2018-04-23
- 2.0.0 — 2017-10-05
- 1.1.2 — 2017-09-16
- 1.1.1 — 2017-08-21
- 1.1.0 — 2017-08-21
- 1.0.0 — 2017-08-20

## README

# await-spawn

> `child_process.spawn()` wrapped in a `Promise` for doing async/await.

[![npm](https://img.shields.io/npm/v/await-spawn.svg)](https://www.npmjs.com/package/await-spawn)
![Node version](https://img.shields.io/node/v/await-spawn.svg)
[![Build Status](https://travis-ci.org/ralphtheninja/await-spawn.svg?branch=master)](https://travis-ci.org/ralphtheninja/await-spawn)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```
$ npm i await-spawn -S
```

## Usage

```js
const spawn = require('await-spawn')

const main = async () => {
  try {
    const bl = await spawn('ls', ['-al'])
    console.log(bl.toString())
  } catch (e) {
    console.log(e.stderr.toString())
  }
}

main()
```

## Api

Exposes a single function, which has the same api as `child_process.spawn()`.

Returns a `Promise` with `.child` set to the spawned child process. The `Promise` resolves to the buffered output of `child.stdout` in the form of a [`BufferList`] object.

If there was an error, the `Promise` rejects with an `Error` object, which has the following extra properties:

* `code` the error code
* `stdout` the buffered output of `stdout` in the form of a [`BufferList`] object
* `stderr` the buffered output of `stderr` in the form of a [`BufferList`] object

Note that `child.stdout` doesn't exist if `options.stdio === 'inherit'`, so the `Promise` resolves to `''`.

## License

MIT

[`BufferList`]: https://github.com/rvagg/bl

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