|
|
@@ -15,35 +15,21 @@ if (!process.env.TABBY_PLUGINS) {
|
|
|
|
|
|
const argv = parseArgs(process.argv, process.cwd())
|
|
|
|
|
|
-loadConfig().then(configStore => {
|
|
|
- const application = new Application(configStore)
|
|
|
+const application = loadConfig().catch(err => {
|
|
|
+ dialog.showErrorBox('Could not read config', err.message)
|
|
|
+ app.exit(1)
|
|
|
+}).then(configStore => {
|
|
|
+ const _application = new Application(configStore)
|
|
|
|
|
|
ipcMain.on('app:new-window', () => {
|
|
|
- application.newWindow()
|
|
|
- })
|
|
|
-
|
|
|
- app.on('activate', () => {
|
|
|
- if (!application.hasWindows()) {
|
|
|
- application.newWindow()
|
|
|
- } else {
|
|
|
- application.focus()
|
|
|
- }
|
|
|
+ _application.newWindow()
|
|
|
})
|
|
|
|
|
|
process.on('uncaughtException' as any, err => {
|
|
|
console.log(err)
|
|
|
- application.broadcast('uncaughtException', err)
|
|
|
+ _application.broadcast('uncaughtException', err)
|
|
|
})
|
|
|
|
|
|
- app.on('second-instance', (_event, newArgv, cwd) => {
|
|
|
- application.handleSecondInstance(newArgv, cwd)
|
|
|
- })
|
|
|
-
|
|
|
- if (!app.requestSingleInstanceLock()) {
|
|
|
- app.quit()
|
|
|
- app.exit(0)
|
|
|
- }
|
|
|
-
|
|
|
if (argv.d) {
|
|
|
electronDebug({
|
|
|
isEnabled: true,
|
|
|
@@ -52,24 +38,43 @@ loadConfig().then(configStore => {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- app.on('ready', async () => {
|
|
|
- if (process.platform === 'darwin') {
|
|
|
- app.dock.setMenu(Menu.buildFromTemplate([
|
|
|
- {
|
|
|
- label: 'New window',
|
|
|
- click () {
|
|
|
- this.app.newWindow()
|
|
|
- },
|
|
|
+ return _application
|
|
|
+})
|
|
|
+
|
|
|
+
|
|
|
+app.on('activate', async () => {
|
|
|
+ if (!(await application).hasWindows()) {
|
|
|
+ (await application).newWindow()
|
|
|
+ } else {
|
|
|
+ (await application).focus()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+app.on('second-instance', async (_event, newArgv, cwd) => {
|
|
|
+ (await application).handleSecondInstance(newArgv, cwd)
|
|
|
+})
|
|
|
+
|
|
|
+if (!app.requestSingleInstanceLock()) {
|
|
|
+ app.quit()
|
|
|
+ app.exit(0)
|
|
|
+}
|
|
|
+
|
|
|
+app.on('ready', async () => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ app.dock.setMenu(Menu.buildFromTemplate([
|
|
|
+ {
|
|
|
+ label: 'New window',
|
|
|
+ click () {
|
|
|
+ this.app.newWindow()
|
|
|
},
|
|
|
- ]))
|
|
|
- }
|
|
|
- application.init()
|
|
|
+ },
|
|
|
+ ]))
|
|
|
+ }
|
|
|
|
|
|
- const window = await application.newWindow({ hidden: argv.hidden })
|
|
|
- await window.ready
|
|
|
- window.passCliArguments(process.argv, process.cwd(), false)
|
|
|
- window.focus()
|
|
|
- })
|
|
|
-}).catch(err => {
|
|
|
- dialog.showErrorBox('Could not read config', err.message)
|
|
|
+ (await application).init()
|
|
|
+
|
|
|
+ const window = await (await application).newWindow({ hidden: argv.hidden })
|
|
|
+ await window.ready
|
|
|
+ window.passCliArguments(process.argv, process.cwd(), false)
|
|
|
+ window.focus()
|
|
|
})
|