From 1bd31bf18c185146e74967553dd1c864a6bda1c5 Mon Sep 17 00:00:00 2001 From: 4gray Date: Tue, 13 Jan 2026 22:43:11 +0100 Subject: [PATCH] fix(electron): use app.isPackaged to detect dev mode Replace custom environment-based dev detection with Electron's built-in app.isPackaged check. Import the app module from Electron and remove reliance on ELECTRON_IS_DEV and the environment file. This simplifies logic, improves reliability of development vs production detection, and reduces dependency on external env vars. --- apps/electron-backend/src/app/app.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/apps/electron-backend/src/app/app.ts b/apps/electron-backend/src/app/app.ts index 847f0e20d..4641995d3 100644 --- a/apps/electron-backend/src/app/app.ts +++ b/apps/electron-backend/src/app/app.ts @@ -1,6 +1,5 @@ -import { BrowserWindow, Menu, screen, shell } from 'electron'; +import { app, BrowserWindow, Menu, screen, shell } from 'electron'; import { join } from 'path'; -import { environment } from '../environments/environment'; import { rendererAppName, rendererAppPort } from './constants'; import { store, WINDOW_BOUNDS } from './services/store.service'; @@ -12,11 +11,14 @@ export default class App { static BrowserWindow; public static isDevelopmentMode() { - const isEnvironmentSet: boolean = 'ELECTRON_IS_DEV' in process.env; - const getFromEnvironment: boolean = - parseInt(process.env.ELECTRON_IS_DEV, 10) === 1; - - return isEnvironmentSet ? getFromEnvironment : !environment.production; + // First check ELECTRON_IS_DEV environment variable (used by E2E tests) + // This allows E2E tests to run in production mode without packaging + if ('ELECTRON_IS_DEV' in process.env) { + return parseInt(process.env.ELECTRON_IS_DEV, 10) === 1; + } + // Fall back to Electron's built-in app.isPackaged + // This is the most reliable way to detect if the app is packaged + return !app.isPackaged; } private static onWindowAllClosed() {