Comparing version 0.3.1 to 0.3.2
27
index.js
@@ -71,5 +71,16 @@ var child_process = require('child_process'), | ||
child.on('close', function(code) { | ||
var _err = null; | ||
if (code !== 0) { | ||
_err = new Error(cmd + 'exited with code ' + code); | ||
_err.cmd = cmd + ' ' + args.join(' ') | ||
_err.code = code | ||
_err.stderr = err | ||
_err.stdout = out | ||
} | ||
stdout.destroy(); | ||
stderr.destroy(); | ||
callback(err, out, code); | ||
callback(_err, out, err, code); | ||
}); | ||
@@ -87,3 +98,3 @@ | ||
child.on('exit', function(code) { | ||
callback(null, null, code); | ||
callback(null, null, null, code); | ||
}); | ||
@@ -113,3 +124,13 @@ | ||
child.on('close', function(code) { | ||
callback(err, out, code); | ||
var _err = null; | ||
if (code !== 0) { | ||
_err = new Error(cmd + 'exited with code ' + code); | ||
_err.cmd = cmd + ' ' + args.join(' ') | ||
_err.code = code | ||
_err.stderr = err | ||
_err.stdout = out | ||
} | ||
callback(_err, out, err, code); | ||
}); | ||
@@ -116,0 +137,0 @@ |
{ | ||
"name": "executive", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "exec for the lazy", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -6,4 +6,4 @@ exec = require('../'); | ||
it('should buffer all stdout', function(done) { | ||
exec.bufferedExec('bash', ['-c', 'echo 1'], {}, function(err, out, code) { | ||
out.should.eq('1\n'); | ||
exec.bufferedExec('bash', ['-c', 'echo 1'], {}, function(err, stdout, stderr) { | ||
stdout.should.eq('1\n'); | ||
done(); | ||
@@ -14,4 +14,4 @@ }); | ||
it('should buffer all stderr', function(done) { | ||
exec.bufferedExec('bash', ['-c', 'doesnotexist'], {}, function(err, out, code) { | ||
err.should.contain('command not found'); | ||
exec.bufferedExec('bash', ['-c', 'doesnotexist'], {}, function(err, stdout, stderr) { | ||
stderr.should.contain('command not found'); | ||
done(); | ||
@@ -24,4 +24,4 @@ }); | ||
it('should buffer all stdout', function(done) { | ||
exec.quietExec('bash', ['-c', 'echo 1'], {}, function(err, out, code) { | ||
out.should.eq('1\n'); | ||
exec.quietExec('bash', ['-c', 'echo 1'], {}, function(err, stdout, stderr) { | ||
stdout.should.eq('1\n'); | ||
done(); | ||
@@ -32,4 +32,4 @@ }); | ||
it('should buffer all stderr', function(done) { | ||
exec.quietExec('bash', ['-c', 'doesnotexist'], {}, function(err, out, code) { | ||
err.should.contain('command not found'); | ||
exec.quietExec('bash', ['-c', 'doesnotexist'], {}, function(err, stdout, stderr) { | ||
stderr.should.contain('command not found'); | ||
done(); | ||
@@ -42,4 +42,4 @@ }); | ||
it('should not buffer stdout', function(done) { | ||
exec.interactiveExec('bash', ['-c', 'echo 1'], {}, function(err, out, code) { | ||
(out === null).should.equal(true); | ||
exec.interactiveExec('bash', ['-c', 'echo 1'], {}, function(err, stdout, stderr) { | ||
(stdout === null).should.equal(true); | ||
done(); | ||
@@ -50,4 +50,4 @@ }); | ||
it('should not buffer stderr', function(done) { | ||
exec.interactiveExec('bash', ['-c', 'doesnotexist'], {}, function(err, out, code) { | ||
(err === null).should.equal(true); | ||
exec.interactiveExec('bash', ['-c', 'doesnotexist'], {}, function(err, stdout, stderr) { | ||
(stderr === null).should.equal(true); | ||
done(); | ||
@@ -54,0 +54,0 @@ }); |
12722
290