Skip to content

Commit

Permalink
issue #70
Browse files Browse the repository at this point in the history
  • Loading branch information
zaggino committed Sep 12, 2016
1 parent 97dee35 commit e8f9c65
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions app/appshell/app-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = [];

Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion app/appshell/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 };
15 changes: 15 additions & 0 deletions app/appshell/shell.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import { handleStartupEvent } from "./squirrel-event-handler";

if (!handleStartupEvent()) {
require("./shell");
require("./main");
}
4 changes: 0 additions & 4 deletions app/shell.ts → app/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit e8f9c65

Please sign in to comment.