Skip to content

Commit 8a1c499

Browse files
committed
bort prompts if SSH connection failed earlier (fixes #165)
1 parent 5900d67 commit 8a1c499

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/transport/ssh.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function SSH(context) {
2525

2626
var fiber = Fiber.current;
2727

28+
var hasFailed = false;
29+
2830
this._connection = new Connection();
2931

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

3436
var currentPrompt = prompts[answers.length];
3537

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

5254
this._connection.on('error', function(err) {
55+
hasFailed = true;
5356
return fiber.throwInto(err);
5457
});
5558

0 commit comments

Comments
 (0)