Code Monkey home page Code Monkey logo

comandante's Introduction

comandante

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

build status

example

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

in a git directory we get:

$ node example/log.js | head -n3
commit ae5045cce4980a87b7151cfe91bc5889951aae39
Author: James Halliday <[email protected]>
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

var comandante = require('comandante')

comandante(cmd, args, opts={})

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

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 do:

npm install comandante

license

MIT

comandante's People

Contributors

jed avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.