diff --git a/src/backend/electron/main.ts b/src/backend/electron/main.ts index 79b873f2a6..9289b6a4ec 100644 --- a/src/backend/electron/main.ts +++ b/src/backend/electron/main.ts @@ -113,18 +113,23 @@ process.on("unhandledRejection", (reason) => { log.error(reason); }); -let appDirPath: string; -let __static: string; +function initializeAppPaths() { + let appDirPath: string; + let __static: string; -if (isDevelopment) { - // __dirnameはdist_electronを指しているので、一つ上のディレクトリに移動する - appDirPath = path.resolve(__dirname, ".."); - __static = path.join(appDirPath, "public"); -} else { - appDirPath = path.dirname(app.getPath("exe")); - process.chdir(appDirPath); - __static = __dirname; + if (isDevelopment) { + // __dirnameはdist_electronを指しているので、一つ上のディレクトリに移動する + appDirPath = path.resolve(__dirname, ".."); + __static = path.join(appDirPath, "public"); + } else { + appDirPath = path.dirname(app.getPath("exe")); + process.chdir(appDirPath); + __static = __dirname; + } + + return { appDirPath, __static }; } +const { appDirPath, __static } = initializeAppPaths(); protocol.registerSchemesAsPrivileged([ { scheme: "app", privileges: { secure: true, standard: true, stream: true } },