1
1
mirror of https://github.com/Eugeny/tabby.git synced 2025-01-05 01:23:19 +03:00

cli fixes

This commit is contained in:
Eugene Pankov 2021-05-16 15:57:17 +02:00
parent fa07fdcb64
commit 3f40098ffb
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
4 changed files with 9 additions and 5 deletions

View File

@ -14,7 +14,8 @@ export class LastCLIHandler extends CLIHandler {
async handle (event: CLIEvent): Promise<boolean> { async handle (event: CLIEvent): Promise<boolean> {
if (event.secondInstance) { if (event.secondInstance) {
this.hostApp.newWindow() this.hostApp.newWindow()
return true
} }
return true return false
} }
} }

View File

@ -127,7 +127,8 @@ export class HostAppService {
}) })
electron.ipcRenderer.on('cli', (_$event, argv: any, cwd: string, secondInstance: boolean) => this.zone.run(async () => { electron.ipcRenderer.on('cli', (_$event, argv: any, cwd: string, secondInstance: boolean) => this.zone.run(async () => {
this.logger.info('CLI arguments received:', argv) const event = { argv, cwd, secondInstance }
this.logger.info('CLI arguments received:', event)
const cliHandlers = injector.get(CLIHandler) as unknown as CLIHandler[] const cliHandlers = injector.get(CLIHandler) as unknown as CLIHandler[]
cliHandlers.sort((a, b) => b.priority - a.priority) cliHandlers.sort((a, b) => b.priority - a.priority)
@ -137,7 +138,8 @@ export class HostAppService {
if (handled && handler.firstMatchOnly) { if (handled && handler.firstMatchOnly) {
continue continue
} }
if (await handler.handle({ argv, cwd, secondInstance })) { if (await handler.handle(event)) {
this.logger.info('CLI handler matched:', handler.constructor.name)
handled = true handled = true
} }
} }

View File

@ -70,7 +70,7 @@ export function stringifyKeySequence (events: EventData[]): string[] {
Quote: '\'', Quote: '\'',
BracketLeft: '[', BracketLeft: '[',
BracketRight: ']', BracketRight: ']',
}[key] || key }[key] ?? key
} }
itemKeys.push(key) itemKeys.push(key)

View File

@ -190,7 +190,8 @@ export class Session extends BaseSession {
}) })
} }
let cwd = options.cwd ?? process.env.HOME // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
let cwd = options.cwd || process.env.HOME
if (!fs.existsSync(cwd)) { if (!fs.existsSync(cwd)) {
console.warn('Ignoring non-existent CWD:', cwd) console.warn('Ignoring non-existent CWD:', cwd)