Просмотр исходного кода

Adding env handlement for ssh profile sessions (#6242)

woodmeal 3 лет назад
Родитель
Сommit
25f5cf04ea
2 измененных файлов с 10 добавлено и 1 удалено
  1. 8 0
      tabby-ssh/src/session/ssh.ts
  2. 2 1
      tabby-ssh/tsconfig.typings.json

+ 8 - 0
tabby-ssh/src/session/ssh.ts

@@ -306,6 +306,14 @@ export class SSHSession {
                     this.authUsername = 'root'
                 }
             }
+            if (this.authUsername?.startsWith('$')) {
+                try {
+                    const result = process.env[this.authUsername.slice(1)]
+                    this.authUsername = result ?? this.authUsername
+                } catch {
+                    this.authUsername = 'root'
+                }
+            }
 
             ssh.connect({
                 host: this.profile.options.host.trim(),

+ 2 - 1
tabby-ssh/tsconfig.typings.json

@@ -10,6 +10,7 @@
     "paths": {
       "tabby-*": ["../../tabby-*"],
       "*": ["../../app/node_modules/*"]
-    }
+    },
+    "types": ["node"]
   }
 }