1
1
mirror of https://github.com/Eugeny/tabby.git synced 2025-01-02 23:45:45 +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> {
if (event.secondInstance) {
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 () => {
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[]
cliHandlers.sort((a, b) => b.priority - a.priority)
@ -137,7 +138,8 @@ export class HostAppService {
if (handled && handler.firstMatchOnly) {
continue
}
if (await handler.handle({ argv, cwd, secondInstance })) {
if (await handler.handle(event)) {
this.logger.info('CLI handler matched:', handler.constructor.name)
handled = true
}
}

View File

@ -70,7 +70,7 @@ export function stringifyKeySequence (events: EventData[]): string[] {
Quote: '\'',
BracketLeft: '[',
BracketRight: ']',
}[key] || key
}[key] ?? 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)) {
console.warn('Ignoring non-existent CWD:', cwd)