Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 64 lines (45 sloc) 1.538 kb
b6ab98d @substack docks
authored
1 # commandante
2
3 Spawn commands returning a duplex stream. Emit stderr when the command exits
4 with a non-zero code.
5
6 ## example
7
8 ``` js
9 var run = require('commandante');
10 run('git', [ 'log' ]).pipe(process.stdout);
11 ```
12
13 in a git directory we get:
14
15 ```
16 $ node example/log.js | head -n3
17 commit ae5045cce4980a87b7151cfe91bc5889951aae39
18 Author: James Halliday <mail@substack.net>
19 Date: Tue Oct 2 09:08:18 2012 -0700
20 ```
21
22 in a non-git directory we get:
23
24 ```
25 events.js:66
26 throw arguments[1]; // Unhandled 'error' event
27 ^
28 Error: non-zero exit code 128: fatal: Not a git repository (or any of the parent directories): .git
29
30 at ChildProcess.<anonymous> (/home/substack/projects/comandante/index.js:19:27)
31 at ChildProcess.EventEmitter.emit (events.js:91:17)
32 at maybeClose (child_process.js:634:16)
33 at Socket.ChildProcess.spawn.stdin (child_process.js:805:11)
34 at Socket.EventEmitter.emit (events.js:88:17)
35 at Socket._destroy.destroyed (net.js:358:10)
36 at process.startup.processNextTick.process._tickCallback (node.js:244:9)
37 ```
38
39 # methods
40
41 ``` js
42 var commandante = require('commandante')
43 ```
44
45 ## commandante(cmd, args, opts={})
46
47 Spawn a new process like `require('child_process')`.spawn()`, except the return
48 value is a duplex stream combining `stdout` and `stdin`.
49
50 If the process exits with a non-zero status, emit an `'error'` event with the
51 stderr data and the code in an informative message.
52
53 # install
54
55 With [npm](https://npmjs.org) do:
56
57 ```
58 npm install comandante
59 ```
60
61 # license
62
63 MIT
Something went wrong with that request. Please try again.