From 98a7801803ee069b5019d4b19e9e40a1d493123c Mon Sep 17 00:00:00 2001 From: Domain Date: Wed, 29 Aug 2018 17:02:02 +0800 Subject: [PATCH] Follow the general Terminus style --- terminus-ssh/src/api.ts | 27 +++++++------------ .../editConnectionModal.component.ts | 6 ++--- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index 61177de9..85f9cd46 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -30,27 +30,22 @@ export class SSHSession extends BaseSession { let dataString = data.toString() this.emitOutput(dataString) - if (this.scripts && this.scripts.length > 0) - { + if (this.scripts && this.scripts.length > 0) { let found = false - for (let i = 0; i < this.scripts.length; i++) - { - if (dataString.indexOf(this.scripts[i].expect) >= 0) - { + for (let i = 0; i < this.scripts.length; i++) { + if (dataString.indexOf(this.scripts[i].expect) >= 0) { console.log("Executing: " + this.scripts[i].send) this.shell.write(this.scripts[i].send + "\n") this.scripts.splice(i, 1) i-- found = true } - else - { + else { break; } } - if (found) - { + if (found) { this.executeScripts() } } @@ -66,19 +61,15 @@ export class SSHSession extends BaseSession { } executeScripts () { - if (this.scripts && this.scripts.length > 0) - { - for (let i = 0; i < this.scripts.length; i++) - { - if (!this.scripts[i].expect) - { + if (this.scripts && this.scripts.length > 0) { + for (let i = 0; i < this.scripts.length; i++) { + if (!this.scripts[i].expect) { console.log("Executing: " + this.scripts[i].send) this.shell.write(this.scripts[i].send + "\n") this.scripts.splice(i, 1) i-- } - else - { + else { break; } } diff --git a/terminus-ssh/src/components/editConnectionModal.component.ts b/terminus-ssh/src/components/editConnectionModal.component.ts index aad1f669..d33b3053 100644 --- a/terminus-ssh/src/components/editConnectionModal.component.ts +++ b/terminus-ssh/src/components/editConnectionModal.component.ts @@ -40,8 +40,7 @@ export class EditConnectionModalComponent { up (script: LoginScript) { let index = this.connection.scripts.indexOf(script) - if (index > 0) - { + if (index > 0) { this.connection.scripts.splice(index, 1); this.connection.scripts.splice(index - 1, 0, script); } @@ -49,8 +48,7 @@ export class EditConnectionModalComponent { down (script: LoginScript) { let index = this.connection.scripts.indexOf(script) - if (index >= 0 && index < this.connection.scripts.length - 1) - { + if (index >= 0 && index < this.connection.scripts.length - 1) { this.connection.scripts.splice(index, 1); this.connection.scripts.splice(index + 1, 0, script); }