Skip to content

Commit

Permalink
fix node failure on command error
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Nov 1, 2013
1 parent 7d1f3bd commit 587271e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ function run(baseDir, privKey, cmd, keyMode, cb) {
}
self(err, proc.stdoutBuffer, proc.stderrBuffer, exitCode)
})
proc.on('error', function (err) {
// prevent node from throwing an error. The error handling is
// done in the 'close' handler.
})
},
function(err, stdout, stderr, exitCode) {
// cleanup temp files
Expand Down
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ describe('gitane', function() {
})
})

it('should correctly handle failed commands', function (done) {
gitane.run(os.tmpDir(), 'testkey', 'notarealcommand', function (err, stdout, stderr, exitCode) {
expect(err).to.be.ok
expect(exitCode).to.be.ok
done()
})
})

}),

describe('#writeFiles', function() {
Expand Down

0 comments on commit 587271e

Please sign in to comment.