diff --git a/app/common/config-util.ts b/app/common/config-util.ts index 66843abe..5016f1d0 100644 --- a/app/common/config-util.ts +++ b/app/common/config-util.ts @@ -1,4 +1,3 @@ -import electron from "electron"; import fs from "fs"; import path from "path"; @@ -9,14 +8,12 @@ import type * as z from "zod"; import {configSchemata} from "./config-schemata"; import * as EnterpriseUtil from "./enterprise-util"; import Logger from "./logger-util"; +import {app, dialog} from "./remote"; export type Config = { [Key in keyof typeof configSchemata]: z.output; }; -/* To make the util runnable in both main and renderer process */ -const {app, dialog} = process.type === "renderer" ? electron.remote : electron; - const logger = new Logger({ file: "config-util.log", }); diff --git a/app/common/default-util.ts b/app/common/default-util.ts index 8e53d376..5256dc31 100644 --- a/app/common/default-util.ts +++ b/app/common/default-util.ts @@ -1,7 +1,6 @@ -import electron from "electron"; import fs from "fs"; -const {app} = process.type === "renderer" ? electron.remote : electron; +import {app} from "./remote"; let setupCompleted = false; diff --git a/app/common/logger-util.ts b/app/common/logger-util.ts index bf4c88c9..44f9af75 100644 --- a/app/common/logger-util.ts +++ b/app/common/logger-util.ts @@ -4,10 +4,9 @@ import fs from "fs"; import os from "os"; import {initSetUp} from "./default-util"; +import {app} from "./remote"; import {captureException, sentryInit} from "./sentry-util"; -const {app} = process.type === "renderer" ? electron.remote : electron; - interface LoggerOptions { file?: string; } diff --git a/app/common/remote.ts b/app/common/remote.ts new file mode 100644 index 00000000..49638de3 --- /dev/null +++ b/app/common/remote.ts @@ -0,0 +1,4 @@ +import electron from "electron"; + +export const {app, dialog} = + process.type === "renderer" ? electron.remote : electron; diff --git a/app/common/sentry-util.ts b/app/common/sentry-util.ts index 47c7f6ed..8c293f22 100644 --- a/app/common/sentry-util.ts +++ b/app/common/sentry-util.ts @@ -1,8 +1,6 @@ -import electron from "electron"; - import {init} from "@sentry/electron"; -const {app} = process.type === "renderer" ? electron.remote : electron; +import {app} from "./remote"; export const sentryInit = (): void => { if (app.isPackaged) {