From 1668be72847b235cff935fdd90619f3184000a91 Mon Sep 17 00:00:00 2001 From: Daniel Pigott Date: Tue, 5 Jan 2016 09:15:37 +1100 Subject: [PATCH 1/2] Changed ssh stream to listen for 'end' event rather than 'close' --- lib/transport/ssh.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/transport/ssh.js b/lib/transport/ssh.js index 5bd88dd..bfe2465 100644 --- a/lib/transport/ssh.js +++ b/lib/transport/ssh.js @@ -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) { From c1e583c70cb7288e3bff57dafca29acda70b1028 Mon Sep 17 00:00:00 2001 From: Daniel Pigott Date: Tue, 5 Jan 2016 09:29:58 +1100 Subject: [PATCH 2/2] Updated ssh transport test to use end event rather than close --- test/test.transport.ssh.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/test.transport.ssh.js b/test/test.transport.ssh.js index c752802..6b7852a 100644 --- a/test/test.transport.ssh.js +++ b/test/test.transport.ssh.js @@ -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'); @@ -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"'); @@ -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 }); @@ -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 }); @@ -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 }); @@ -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() { @@ -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 });