handle directory paths supplied on cli (fixes #90)

This commit is contained in:
Eugene Pankov 2017-07-10 17:57:58 +02:00
parent 29a6fb60de
commit 475c4f91be
2 changed files with 17 additions and 4 deletions

View File

@ -9,12 +9,12 @@ export class ElectronService {
clipboard: any
globalShortcut: any
screen: any
remote: any
private electron: any
private remoteElectron: any
constructor () {
this.electron = require('electron')
this.remoteElectron = this.remoteRequire('electron')
this.remote = this.electron.remote
this.app = this.electron.remote.app
this.screen = this.electron.remote.screen
this.dialog = this.electron.remote.dialog
@ -25,6 +25,6 @@ export class ElectronService {
}
remoteRequire (name: string): any {
return this.electron.remote.require(name)
return this.remote.require(name)
}
}

View File

@ -1,7 +1,7 @@
import * as fs from 'mz/fs'
import * as path from 'path'
import { Injectable } from '@angular/core'
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, ConfigService, HostAppService } from 'terminus-core'
import { HotkeysService, ToolbarButtonProvider, IToolbarButton, AppService, ConfigService, HostAppService, ElectronService } from 'terminus-core'
import { SessionsService } from './services/sessions.service'
import { ShellsService } from './services/shells.service'
@ -14,6 +14,7 @@ export class ButtonProvider extends ToolbarButtonProvider {
private sessions: SessionsService,
private config: ConfigService,
private shells: ShellsService,
electron: ElectronService,
hostApp: HostAppService,
hotkeys: HotkeysService,
) {
@ -31,6 +32,18 @@ export class ButtonProvider extends ToolbarButtonProvider {
}
}
})
if (!electron.remote.process.env.DEV) {
setImmediate(async () => {
let argv: string[] = electron.remote.process.argv
for (let arg of argv.slice(1)) {
if (await fs.exists(arg)) {
if ((await fs.stat(arg)).isDirectory()) {
this.openNewTab(arg)
}
}
}
})
}
}
async openNewTab (cwd?: string): Promise<void> {