# comandante

> spawn() that returns a duplex stream and emits errors with stderr data on non-zero exit codes

Latest version **0.0.1** (published 2012-10-04) · MIT license · 0 weekly downloads

## Install

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

## 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.0.1 |
| Published | 2012-10-04 |
| First published | 2012-10-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | James Halliday |
| Maintainers | substack |
| Keywords | spawn, stream, duplex, stderr, exit, code, non-zero |

## Links

- npm: https://www.npmjs.com/package/comandante
- Repository: https://github.com/substack/comandante
- npm.io page: https://npm.io/package/comandante

## Dependencies (1)

- [duplexer](https://npm.io/package/duplexer.md) ~0.0.2

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2012-10-04
- 0.0.0 — 2012-10-02

## README

# commandante

Spawn commands returning a duplex stream. Emit stderr when the command exits
with a non-zero code.

[![build status](https://secure.travis-ci.org/substack/comandante.png)](http://travis-ci.org/substack/comandante)

## example

``` js
var run = require('commandante');
run('git', [ 'log' ]).pipe(process.stdout);
```

in a git directory we get:

```
$ node example/log.js | head -n3
commit ae5045cce4980a87b7151cfe91bc5889951aae39
Author: James Halliday <mail@substack.net>
Date:   Tue Oct 2 09:08:18 2012 -0700
```

in a non-git directory we get:

```
events.js:66
        throw arguments[1]; // Unhandled 'error' event
                       ^
Error: non-zero exit code 128: fatal: Not a git repository (or any of the parent directories): .git

    at ChildProcess.<anonymous> (/home/substack/projects/comandante/index.js:19:27)
    at ChildProcess.EventEmitter.emit (events.js:91:17)
    at maybeClose (child_process.js:634:16)
    at Socket.ChildProcess.spawn.stdin (child_process.js:805:11)
    at Socket.EventEmitter.emit (events.js:88:17)
    at Socket._destroy.destroyed (net.js:358:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
```

# methods

``` js
var commandante = require('commandante')
```

## commandante(cmd, args, opts={})

Spawn a new process like `require('child_process')`.spawn()`, except the return
value is a duplex stream combining `stdout` and `stdin`.

If the process exits with a non-zero status, emit an `'error'` event with the
stderr data and the code in an informative message.

If `opts.showCommand` is not `false`, show the actual command in the informative
error message. If you are running a command with passwords in the command
arguments make sure to set `showCommand` to `false`.

# install

With [npm](https://npmjs.org) do:

```
npm install comandante
```

# license

MIT

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