This commit is contained in:
Eugene Pankov 2021-01-02 20:24:26 +01:00
parent 4d9cc91e91
commit 3365b143d8
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
9 changed files with 23 additions and 16 deletions

View File

@ -5,7 +5,7 @@ export function parseArgs (argv: string[], cwd: string): any {
argv = argv.slice(1)
}
return require('yargs')
return require('yargs/yargs')(argv.slice(1))
.usage('terminus [command] [arguments]')
.command('open [directory]', 'open a shell in a directory', {
directory: { type: 'string', 'default': cwd },
@ -41,5 +41,5 @@ export function parseArgs (argv: string[], cwd: string): any {
type: 'boolean',
})
.help('help')
.parse(argv.slice(1))
.parse()
}

View File

@ -42,7 +42,6 @@ module.exports = {
mz: 'commonjs mz',
npm: 'commonjs npm',
path: 'commonjs path',
yargs: 'commonjs yargs',
util: 'commonjs util',
'source-map-support': 'commonjs source-map-support',
'windows-swca': 'commonjs windows-swca',
@ -54,4 +53,6 @@ module.exports = {
'process.type': '"main"',
}),
],
// Ignore warnings due to yarg's dynamic module loading
ignoreWarnings: [/node_modules\/yargs/],
}

View File

@ -52,7 +52,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
super.ngOnInit()
setImmediate(() => {
this.setTitle(this.connection.name)
this.setTitle(this.connection!.name)
})
}
@ -65,7 +65,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
this.session = this.injector.get(SerialService).createSession(this.connection)
this.session.serviceMessage$.subscribe(msg => {
this.write(`\r\n${colors.black.bgWhite(' serial ')} ${msg}\r\n`)
this.session.resize(this.size.columns, this.size.rows)
this.session?.resize(this.size.columns, this.size.rows)
})
this.attachSessionHandlers()
this.write(`Connecting to `)
@ -108,7 +108,7 @@ export class SerialTabComponent extends BaseTerminalTabComponent {
name: x.toString(), result: x,
})))
this.serialPort.update({ baudRate: rate })
this.connection.baudrate = rate
this.connection!.baudrate = rate
}
ngOnDestroy () {

View File

@ -127,7 +127,7 @@ export class SerialService {
(this.app.getParentTab(tab) ?? tab).color = connection.color
}
setTimeout(() => {
this.app.activeTab.emitFocused()
this.app.activeTab?.emitFocused()
})
return tab
} catch (error) {

View File

@ -177,7 +177,7 @@ export class SSHSession extends BaseSession {
if (match) {
this.logger.info('Executing script: "' + cmd + '"')
this.shell.write(cmd + '\n')
this.shell!.write(cmd + '\n')
this.scripts = this.scripts.filter(x => x !== script)
} else {
if (script.optional) {
@ -380,7 +380,7 @@ export class SSHSession extends BaseSession {
for (const script of this.scripts) {
if (!script.expect) {
console.log('Executing script:', script.send)
this.shell.write(script.send + '\n')
this.shell!.write(script.send + '\n')
this.scripts = this.scripts.filter(x => x !== script)
} else {
break

View File

@ -33,6 +33,10 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
}
ngOnInit (): void {
if (!this.connection) {
throw new Error('Connection not set')
}
this.logger = this.log.create('terminalTab')
this.enableDynamicTitle = !this.connection.disableDynamicTitle
@ -58,7 +62,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
super.ngOnInit()
setImmediate(() => {
this.setTitle(this.connection.name)
this.setTitle(this.connection!.name)
})
}
@ -150,7 +154,7 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
showPortForwarding (): void {
const modal = this.ngbModal.open(SSHPortForwardingModalComponent).componentInstance as SSHPortForwardingModalComponent
modal.session = this.session
modal.session = this.session!
}
async reconnect (): Promise<void> {
@ -163,14 +167,14 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
if (!this.session?.open) {
return true
}
if (!(this.connection.warnOnClose ?? this.config.store.ssh.warnOnClose)) {
if (!(this.connection?.warnOnClose ?? this.config.store.ssh.warnOnClose)) {
return true
}
return (await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: `Disconnect from ${this.connection.host}?`,
message: `Disconnect from ${this.connection?.host}?`,
buttons: ['Cancel', 'Disconnect'],
defaultId: 1,
}

View File

@ -44,14 +44,14 @@ export class WinSCPContextMenu extends TabContextMenuItemProvider {
if (!this.getPath()) {
return []
}
if (!(tab instanceof SSHTabComponent)) {
if (!(tab instanceof SSHTabComponent) || !tab.connection) {
return []
}
return [
{
label: 'Launch WinSCP',
click: (): void => {
this.launchWinSCP(tab.connection)
this.launchWinSCP(tab.connection!)
},
},
]

View File

@ -171,7 +171,7 @@ export default class TerminalModule { // eslint-disable-line @typescript-eslint/
argv = argv.slice(1)
}
if (require('yargs').parse(argv.slice(1))._[0] !== 'open'){
if (require('yargs/yargs')(argv.slice(1)).parse()._[0] !== 'open'){
app.ready$.subscribe(() => {
terminal.openTab()
})

View File

@ -74,4 +74,6 @@ module.exports = {
'ngx-toastr',
/^terminus-/,
],
// Ignore warnings due to yarg's dynamic module loading
ignoreWarnings: [/node_modules\/yargs/],
}