# p-spawn

> Yet another spawn promise!

Latest version **0.5.5** (published 2020-09-15) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.5 |
| Published | 2020-09-15 |
| First published | 2017-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=12.0.0 |
| Dependencies | 0 |
| Unpacked size | 26.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jeremy Chone |
| Maintainers | jeremychone |
| Keywords | child_process, spawn, promise, async, await |

## Links

- npm: https://www.npmjs.com/package/p-spawn
- Repository: https://github.com/BriteSnow/node-p-spawn
- Homepage: https://github.com/BriteSnow/node-p-spawn#readme
- Issues: https://github.com/BriteSnow/node-p-spawn/issues
- npm.io page: https://npm.io/package/p-spawn

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

- 0.5.5 (latest) — 2020-09-15
- 0.5.4 — 2020-07-18
- 0.5.3 — 2020-06-19
- 0.5.2 — 2020-06-19
- 0.5.1 — 2020-05-20
- 0.5.0 — 2019-11-28
- 0.4.1 — 2018-05-05
- 0.4.0 — 2018-04-09
- 0.3.0 — 2017-06-12
- 0.2.1 — 2017-05-21
- 0.2.0 — 2017-05-14
- 0.1.7 — 2017-05-13
- 0.1.6 — 2017-05-08
- 0.1.5 — 2017-05-08
- 0.1.4 — 2017-05-08
- … 4 more at https://npm.io/package/p-spawn/versions

## README

Yet another spawn promise. (Zero dependency!)

- Promisified child_process.spawn, with more options
- stdout/stderr to console by default. 
- Route stdout or stderr to file.
- Can run spawn as detached (promise will return with handle)
- Typescript definitions


Notes: 
- Require node.js > 8.0 (if you need more support, log ticket)
- Warning: From 0.4.0 needs to be imported as `{ spawn }`

```js
import { spawn } from 'p-spawn'
// or `const {spawn } from 'p-spawn'

await spawn(cmd, args, opts); // return Promise
```

[doc](src/index.ts)

Examples:

```js
const { spawn } = require("p-spawn");


async function test(){
  // will console log the stdout and stderr
  await spawn("echo", ["hello world"]);


  // will not console log the stdout but rather to forward in onStdout
  var txt = [];
  await spawn("echo", ["hello world"], {
    onStdout: (data) => {
      txt.push(data.toString());
    }
  });
  console.log(txt.join("\n"));

  // we an pass spawn options as well
  await spawn("pwd", {
    cwd: "./test",
    onStdout: (data) => {
      txt.push(data.toString());
    }
  });

  // we an pass spawn options as well
  var result = await spawn("echo",["hello world"], {capture: "stdout"});

  console.log(result.stdout); // "hello world"  
}

```

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