Skip to content

Commit

Permalink
Merge pull request #115 from crusepartnership/master
Browse files Browse the repository at this point in the history
Changed ssh stream to listen for 'end' event rather than 'close'
  • Loading branch information
pstadler committed Jan 5, 2016
2 parents 543eb0f + c1e583c commit 7a4a6d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/transport/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ SSH.prototype._exec = function(command, options) {
result.code = code;
});

stream.on('close', function() {
stream.on('end', function() {
if(result.code === 0) {
self._logger.success('ok');
} else if(options.failsafe) {
Expand Down
14 changes: 7 additions & 7 deletions test/test.transport.ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe('transport/ssh', function() {
SSH2_EXEC_STREAM_MOCK.on.withArgs('data').firstCall.args[1]('output');
SSH2_EXEC_STREAM_MOCK.on.withArgs('data').lastCall.args[1]('output'); // byline mock
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](0);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

var result = ssh._exec('command');
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('transport/ssh', function() {

SSH2_EXEC_STREAM_MOCK.on.withArgs('data').lastCall.args[1]('output'); // byline mock
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](0);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

ssh._exec('echo "hello world"');
Expand All @@ -249,7 +249,7 @@ describe('transport/ssh', function() {

SSH2_EXEC_STREAM_MOCK.on.withArgs('data').lastCall.args[1]('output'); // byline mock
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](0);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

ssh._exec('echo "hello world"', { silent: false });
Expand All @@ -271,7 +271,7 @@ describe('transport/ssh', function() {
SSH2_EXEC_STREAM_MOCK.on.withArgs('data').firstCall.args[1]('silent\n');
SSH2_EXEC_STREAM_MOCK.on.withArgs('data').lastCall.args[1]('silent\n'); // byline mock
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](0);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

var result = ssh._exec('echo "silent"', { silent: true });
Expand Down Expand Up @@ -303,7 +303,7 @@ describe('transport/ssh', function() {
// byline mock
SSH2_EXEC_STREAM_MOCK.stderr.on.withArgs('data').lastCall.args[1]('not found\n');
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](127);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

var result = ssh._exec('invalid-command', { failsafe: true });
Expand Down Expand Up @@ -334,7 +334,7 @@ describe('transport/ssh', function() {
// byline mock
SSH2_EXEC_STREAM_MOCK.stderr.on.withArgs('data').lastCall.args[1]('not found\n');
SSH2_EXEC_STREAM_MOCK.on.withArgs('exit').lastCall.args[1](127);
SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

expect(function() {
Expand Down Expand Up @@ -362,7 +362,7 @@ describe('transport/ssh', function() {
setImmediate(function() {
SSH2_EXEC_STUB.lastCall.args[2](null, SSH2_EXEC_STREAM_MOCK);

SSH2_EXEC_STREAM_MOCK.on.withArgs('close').lastCall.args[1]();
SSH2_EXEC_STREAM_MOCK.on.withArgs('end').lastCall.args[1]();
});

ssh._exec('echo "test"', { exec: EXEC_OPTIONS });
Expand Down

0 comments on commit 7a4a6d4

Please sign in to comment.