Permalink
Browse files

initial thing ripped out of git-file

  • Loading branch information...
0 parents commit 95e4802118459f2eec942cba789bd451702e3aa4 @substack committed Oct 2, 2012
Showing with 21 additions and 0 deletions.
  1. +21 −0 index.js
@@ -0,0 +1,21 @@
+var through = require('through');
+var spawn = require('child_process').spawn;
+
+module.exports = function (cmd, args) {
+ if (Array.isArray(cmd)) {
+ args = cmd.slice(1);
+ cmd = cmd[0];
+ }
+
+ var ps = spawn(cmd, args);
+ var err = '';
+ ps.stderr.on('data', function (buf) { err += buf });
+
+ ps.on('exit', function (code) {
+ if (code === 0) return;
+ tr.emit('error', 'non-zero exit code ' + code + ': ' + err);
+ });
+
+ var tr = ps.stdout.pipe(through());
+ return tr;
+};

0 comments on commit 95e4802

Please sign in to comment.