# spown

> Spawn child process

Latest version **0.1.2** (published 2020-10-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install spown
pnpm add spown
yarn add spown
bun add spown
```

## Health

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

Positive: has types; no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2020-10-13 |
| First published | 2020-09-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=12.13.0 |
| Dependencies | 3 |
| Unpacked size | 11.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 81 |
| Maintainers | fosimus, psxcode, deepsweet |
| Keywords | spawn, child_process |

## Links

- npm: https://www.npmjs.com/package/spown
- Repository: https://github.com/nextools/metarepo
- Homepage: https://github.com/nextools/metarepo#readme
- Issues: https://github.com/nextools/metarepo/issues
- npm.io page: https://npm.io/package/spown

## Dependencies (3)

- [unchunk](https://npm.io/package/unchunk.md) ^0.2.0
- [cross-spawn](https://npm.io/package/cross-spawn.md) ^7.0.3
- [signal-exit](https://npm.io/package/signal-exit.md) ^3.0.3

## Recent versions

- 0.1.2 (latest) — 2020-10-13
- 0.1.1 — 2020-09-26
- 0.1.0 — 2020-09-25
- 0.0.0 — 2020-09-20

## README

# spown ![npm](https://flat.badgen.net/npm/v/spown)

Spawn child process.

## Install

```sh
$ yarn add spown
```

## Usage

```ts
type TSpawnChildProcessOptions = {
  argv0?: string,
  cwd?: string,
  env?: NodeJS.ProcessEnv,
  stdin?: Stream | null,
  stdout?: Stream | null,
  stderr?: Stream | null,
  uid?: number,
  gid?: number,
  serialization?: 'json' | 'advanced'
}

const spawnChildProcess: (command: string, options?: TSpawnChildProcessOptions) => Promise<{
  stdout: string | null,
  stderr: string | null
}>
```

```ts
type TSpawnChildProcessStreamOptions = {
  argv0?: string,
  cwd?: string,
  env?: NodeJS.ProcessEnv,
  stdin?: Stream | null,
  stdout?: Stream | null,
  stderr?: Stream | null,
  shouldCreateIpcChannel?: boolean,
  uid?: number,
  gid?: number,
  serialization?: 'json' | 'advanced'
}

const spawnChildProcessStream: (command: string, options?: TSpawnChildProcessStreamOptions) => ChildProcess
```

```ts
import { spawnChildProcess, spawnChildProcessStream } from 'spown'
import { unchunkString } from 'unchunk'

console.log(
  await spawnChildProcess('ls /')
)
// {
//   stdout: 'Applications  Library  System  …',
//   stderr: ''
// }

try {
  await spawnChildProcess('ls /foo')
} catch (e) {
  console.error(e.message)
  // ls: cannot access '/foo': No such file or directory
  console.error(e.exitCode)
  // 2
}

const childProcess = spawnChildProcessStream('ls /foo')
const stderr = await unchunkString(childProcess.stderr)

console.log(stderr)
// ls: cannot access '/foo': No such file or directory
```

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