This commit is contained in:
Eugene Pankov 2021-02-01 11:40:49 +01:00
parent 43a27a7b7c
commit 8695003c74
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4
3 changed files with 11 additions and 11 deletions

View file

@ -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

View file

@ -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(() => {

View file

@ -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()
}