Eugene Pankov 4 years ago
parent
commit
8695003c74

+ 7 - 7
terminus-serial/src/api.ts

@@ -42,8 +42,8 @@ export interface SerialPortInfo {
     description?: string
 }
 
-export type InputMode = null | 'readline'
-export type NewlineMode = null | 'cr' | 'lf' | 'crlf'
+export type InputMode = null | 'readline' // eslint-disable-line @typescript-eslint/no-type-alias
+export type NewlineMode = null | 'cr' | 'lf' | 'crlf' // eslint-disable-line @typescript-eslint/no-type-alias
 
 export class SerialSession extends BaseSession {
     scripts?: LoginScript[]
@@ -69,7 +69,7 @@ export class SerialSession extends BaseSession {
             terminal: true,
         } as any)
         this.inputReadlineOutStream.on('data', data => {
-            if (this.connection.inputMode == 'readline') {
+            if (this.connection.inputMode === 'readline') {
                 this.emitOutput(data)
             }
         })
@@ -97,7 +97,7 @@ export class SerialSession extends BaseSession {
     }
 
     write (data: Buffer): void {
-        if (this.connection.inputMode == 'readline') {
+        if (this.connection.inputMode === 'readline') {
             this.inputReadlineInStream.write(data)
         } else {
             this.onInput(data)
@@ -163,7 +163,7 @@ export class SerialSession extends BaseSession {
     }
 
     private onOutputSettled () {
-        if (this.connection.inputMode == 'readline' && !this.inputPromptVisible) {
+        if (this.connection.inputMode === 'readline' && !this.inputPromptVisible) {
             this.resetInputPrompt()
         }
     }
@@ -177,7 +177,7 @@ export class SerialSession extends BaseSession {
     private onOutput (data: Buffer) {
         const dataString = data.toString()
 
-        if (this.connection.inputMode == 'readline') {
+        if (this.connection.inputMode === 'readline') {
             if (this.inputPromptVisible) {
                 clearLine(this.inputReadlineOutStream, 0)
                 this.inputPromptVisible = false
@@ -194,7 +194,7 @@ export class SerialSession extends BaseSession {
                 let cmd = ''
                 if (script.isRegex) {
                     const re = new RegExp(script.expect, 'g')
-                    if (dataString.match(re)) {
+                    if (re.test(dataString)) {
                         cmd = dataString.replace(re, script.send)
                         match = true
                         found = true

+ 1 - 1
terminus-ssh/src/components/sshTab.component.ts

@@ -141,7 +141,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
         }
     }
 
-    protected attachSessionHandlers () {
+    protected attachSessionHandlers (): void {
         const session = this.session!
         super.attachSessionHandlers()
         this.attachSessionHandler(session.destroyed$.subscribe(() => {

+ 3 - 3
terminus-terminal/src/api/baseTerminalTab.component.ts

@@ -569,7 +569,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
         ]
     }
 
-    setSession (session: BaseSession|null, destroyOnSessionClose = false) {
+    setSession (session: BaseSession|null, destroyOnSessionClose = false): void {
         if (session) {
             if (this.session) {
                 this.setSession(null)
@@ -583,7 +583,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
         }
     }
 
-    protected attachSessionHandler (subscription: Subscription) {
+    protected attachSessionHandler (subscription: Subscription): void {
         this.sessionHandlers.push(subscription)
     }
 
@@ -614,7 +614,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
         }))
     }
 
-    protected detachSessionHandlers () {
+    protected detachSessionHandlers (): void {
         for (const s of this.sessionHandlers) {
             s.unsubscribe()
         }