Skip to content

Commit

Permalink
bort prompts if SSH connection failed earlier (fixes #165)
Browse files Browse the repository at this point in the history
  • Loading branch information
pstadler committed May 14, 2017
1 parent 5900d67 commit 8a1c499
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/transport/ssh.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function SSH(context) {

var fiber = Fiber.current;

var hasFailed = false;

this._connection = new Connection();

this._connection.on('keyboard-interactive', function next(name, instructions,
Expand All @@ -33,7 +35,7 @@ function SSH(context) {

var currentPrompt = prompts[answers.length];

if(answers.length < prompts.length) {
if(answers.length < prompts.length && !hasFailed) {
new Fiber(function() {
var answer = self.prompt(currentPrompt.prompt, { hidden: !currentPrompt.echo });
answers.push(answer);
Expand All @@ -50,6 +52,7 @@ function SSH(context) {
});

this._connection.on('error', function(err) {
hasFailed = true;
return fiber.throwInto(err);
});

Expand Down

0 comments on commit 8a1c499

Please sign in to comment.