diff --git a/app/appshell/app-menu.ts b/app/appshell/app-menu.ts index e0a8b4a5f0a..a08906cc2b6 100644 --- a/app/appshell/app-menu.ts +++ b/app/appshell/app-menu.ts @@ -3,7 +3,7 @@ interface MenuItemOptions extends Electron.MenuItemOptions {} import * as _ from "lodash"; import * as assert from "assert"; import { Menu } from "electron"; -import * as main from "../shell"; +import * as shell from "./shell"; const menuTemplate: MenuItemOptions[] = []; @@ -161,7 +161,7 @@ export function addMenuItem( type: isSeparator ? "separator" : "normal", id, label: title, - click: () => main.getMainWindow().webContents.send("executeCommand", id) + click: () => shell.getMainWindow().webContents.send("executeCommand", id) }; if (key) { diff --git a/app/appshell/index.ts b/app/appshell/index.ts index 802acf71d25..c5c3733d64d 100644 --- a/app/appshell/index.ts +++ b/app/appshell/index.ts @@ -5,6 +5,7 @@ import { remote } from "electron"; const app = _.extend({}, require("./app"), remote.require("./appshell/app-menu")); const fs = _.extend({}, require("fs-extra"), require("./fs-additions")); +const shell = remote.require("./appshell/shell"); // prevent using this alias, rather use .remove delete fs.delete; @@ -13,4 +14,4 @@ delete fs.delete; fs.ensureDir(app.getExtensionsFolder()); // this needs to be node-require style export -module.exports = { app, fs, inElectron: true }; +module.exports = { app, fs, shell, inElectron: true }; diff --git a/app/appshell/shell.ts b/app/appshell/shell.ts new file mode 100644 index 00000000000..6cd7b187dca --- /dev/null +++ b/app/appshell/shell.ts @@ -0,0 +1,15 @@ +/* eslint-env node */ + +import { BrowserWindow } from "electron"; + +export function getMainWindow(): Electron.BrowserWindow { + const wins = BrowserWindow.getAllWindows(); + if (wins.length > 1) { + console.warn(`getMainWindow() -> ${wins.length} windows open`); + } + return wins[0]; +} + +export function getProcessArgv() { + return process.argv; +} diff --git a/app/index.ts b/app/index.ts index ab5f8c33bac..4209bd7edd8 100644 --- a/app/index.ts +++ b/app/index.ts @@ -3,5 +3,5 @@ import { handleStartupEvent } from "./squirrel-event-handler"; if (!handleStartupEvent()) { - require("./shell"); + require("./main"); } diff --git a/app/shell.ts b/app/main.ts similarity index 98% rename from app/shell.ts rename to app/main.ts index d56b7f52cc8..4888c958d57 100644 --- a/app/shell.ts +++ b/app/main.ts @@ -156,10 +156,6 @@ app.on("ready", function () { setLoggerWindow(win); }); -export function getMainWindow() { - return wins[0]; -}; - export function restart(query: {} | string) { while (wins.length > 0) { const win = wins.shift();