From e4d9d2b3b7f6093596d5955f13761ce2c0cc484e Mon Sep 17 00:00:00 2001 From: Levi Yan Date: Tue, 6 May 2025 23:04:10 +0800 Subject: [PATCH] refactor: change name: host->hostname --- src/remote-container.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/remote-container.ts b/src/remote-container.ts index 19ce19b..e751ee6 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -78,7 +78,7 @@ export default class RemoteContainer { }); } - async storeHostInfo(host: string, port: number, username: string): Promise { + async storeHostInfo(hostname: string, port: number, username: string): Promise { const sshConfigPath = path.join(os.homedir(), '.ssh', 'config'); // check if the host and related info exist in local ssh config file before saving var canAppendSSHConfig = true @@ -86,8 +86,8 @@ export default class RemoteContainer { var reader = rd.createInterface(fs.createReadStream(sshConfigPath)) for await (const line of reader) { - // host format: hostname:port - if (line.includes(`Host ${host}-${port}`)) { + // host format: hostname-port + if (line.includes(`Host ${hostname}-${port}`)) { // the container ssh info exists canAppendSSHConfig = false break; @@ -97,10 +97,10 @@ export default class RemoteContainer { if (canAppendSSHConfig) { // save the host to the local ssh config file - const hostInConfig = `${host}-${port}` // host format: hostname-port + const host = `${hostname}-${port}` // host: hostname-port const privateKeyPath = this.user.getUserPrivateKeyPath(); const newSShConfigContent = - `\nHost ${hostInConfig}\n HostName ${host}\n Port ${port}\n User ${username}\n PreferredAuthentications publickey\n IdentityFile ${privateKeyPath}\n `; + `\nHost ${host}\n HostName ${hostname}\n Port ${port}\n User ${username}\n PreferredAuthentications publickey\n IdentityFile ${privateKeyPath}\n `; fs.writeFileSync(sshConfigPath, newSShConfigContent, { encoding: 'utf8', flag: 'a' }); console.log('Host registered in local ssh config'); }