Skip to content

Commit debafaf

Browse files
committed
fix: minor cleanup
1 parent 978fdb4 commit debafaf

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

client/src/connection/ssh/auth.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ class AuthPresenterImpl implements AuthPresenter {
4848
presentMultiplePrompts = async (prompts: Prompt[]): Promise<string[]> => {
4949
const answers: string[] = [];
5050
for (const prompt of prompts) {
51-
this.presentSecurePrompt(prompt.prompt).then((answer) => {
52-
answers.push(answer);
53-
});
51+
const answer = await this.presentSecurePrompt(prompt.prompt);
52+
answers.push(answer);
5453
}
5554
return answers;
5655
};

client/src/connection/ssh/index.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@ export interface Config extends BaseConfig {
3939

4040
export function getSession(c: Config): Session {
4141
if (!sessionInstance) {
42-
sessionInstance = new SSHSession();
42+
sessionInstance = new SSHSession(c, new Client());
4343
}
44-
sessionInstance.config = c;
4544
return sessionInstance;
4645
}
4746
export class SSHSession extends Session {
@@ -57,10 +56,10 @@ export class SSHSession extends Session {
5756
private _workDirectory: string;
5857
private _workDirectoryParser: LineParser;
5958

60-
constructor(c?: Config) {
59+
constructor(c?: Config, client?: Client) {
6160
super();
6261
this._config = c;
63-
this._conn = new Client();
62+
this._conn = client;
6463
this._authMethods = ["publickey", "password", "keyboard-interactive"];
6564
this._sessionReady = false;
6665
this._authHandler = new AuthHandler();
@@ -96,12 +95,17 @@ export class SSHSession extends Session {
9695
readyTimeout: SAS_LAUNCH_TIMEOUT,
9796
keepaliveInterval: KEEPALIVE_INTERVAL,
9897
keepaliveCountMax: KEEPALIVE_UNANSWERED_THRESHOLD,
98+
9999
debug: (msg) => {
100100
console.log(msg);
101101
},
102102
authHandler: this.handleSSHAuthentication,
103103
};
104104

105+
if (!this._conn) {
106+
this._conn = new Client();
107+
}
108+
105109
this._conn
106110
.on("ready", () => {
107111
this._conn.shell(this.onShell);
@@ -179,6 +183,7 @@ export class SSHSession extends Session {
179183
this.clearAuthState();
180184
this._workDirectory = undefined;
181185
this._conn.end();
186+
sessionInstance = undefined;
182187
updateStatusBarItem(false);
183188
};
184189

@@ -227,7 +232,7 @@ export class SSHSession extends Session {
227232
if (!line) {
228233
return;
229234
}
230-
const trimmedLine = line.trim();
235+
const trimmedLine = line.trimEnd();
231236
if (trimmedLine.endsWith(LineCodes.RunEndCode)) {
232237
// run completed
233238
this.getResult();

0 commit comments

Comments
 (0)