Skip to content

Commit

Permalink
convert remaining CommonJS modules to ES module syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
szTheory committed Apr 29, 2020
1 parent 673cbd0 commit e629a54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
10 changes: 7 additions & 3 deletions src/main/app_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ function preventMultipleAppInstances(): void {
}
}

function openMinimizedIfAlreadyExists({ win }: { win: BrowserWindow }): void {
function openMinimizedIfAlreadyExists({
win
}: {
win: BrowserWindow | null;
}): void {
app.on("second-instance", () => {
if (win) {
if (win.isMinimized()) {
Expand All @@ -24,15 +28,15 @@ function quitOnWindowsAllClosed(): void {
});
}

function createWindowOnActivate({ win }: { win: BrowserWindow }): void {
function createWindowOnActivate({ win }: { win: BrowserWindow | null }): void {
app.on("activate", () => {
if (!win) {
win = createMainWindow();
}
});
}

export function setupApp({ win }: { win: BrowserWindow }): void {
export function setupApp({ win }: { win: BrowserWindow | null }): void {
preventMultipleAppInstances();
openMinimizedIfAlreadyExists({ win: win });
quitOnWindowsAllClosed();
Expand Down
8 changes: 4 additions & 4 deletions src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ if (is.development && module.hot) {
module.hot.accept();
}

const { app } = require("electron");
const { setupMenu } = require("./menu");
const { init } = require("./init");
const { createMainWindow, setupMainWindow } = require("./window_setup");
import { app } from "electron";
import { setupMenu } from "./menu";
import { init } from "./init";
import { createMainWindow, setupMainWindow } from "./window_setup";

// Maintain reference to window to
// prevent it from being garbage collected
Expand Down
2 changes: 1 addition & 1 deletion src/main/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function setupUserModelId(): void {
app.setAppUserModelId(packageJson.build.appId);
}

export function init({ win }: { win: BrowserWindow }): void {
export function init({ win }: { win: BrowserWindow | null }): void {
setupErrorHandling();
setupContextMenu();
setupUserModelId();
Expand Down
6 changes: 3 additions & 3 deletions src/main/window_setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BrowserWindow, app } from "electron";
const { is } = require("electron-util");
const url = require("url");
const path = require("path");
import { is } from "electron-util";
import url from "url";
import path from "path";

const DEFAULT_WINDOW_WIDTH = 580;
const DEFAULT_WINDOW_HEIGHT = 312;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/add_files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function cleanExifData(exifHash: any): any {
// When finished working with it, it should be closed,
// when -stay_open False will be written to its stdin to exit the process.
//
// const exiftool = require('node-exiftool')
// import exiftool from "node-exiftool"
// const ep = new exiftool.ExiftoolProcess()
//
// ep
Expand Down

0 comments on commit e629a54

Please sign in to comment.