This commit is contained in:
Eugene Pankov
2021-02-01 11:40:49 +01:00
parent 43a27a7b7c
commit 8695003c74
3 changed files with 11 additions and 11 deletions

View File

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

View File

@@ -141,7 +141,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
} }
} }
protected attachSessionHandlers () { protected attachSessionHandlers (): void {
const session = this.session! const session = this.session!
super.attachSessionHandlers() super.attachSessionHandlers()
this.attachSessionHandler(session.destroyed$.subscribe(() => { 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 (session) {
if (this.session) { if (this.session) {
this.setSession(null) 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) 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) { for (const s of this.sessionHandlers) {
s.unsubscribe() s.unsubscribe()
} }