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