From a4edff36191a80b4503305368540290782879174 Mon Sep 17 00:00:00 2001 From: Zamitto Date: Fri, 26 Apr 2024 23:02:53 -0300 Subject: [PATCH] use app.isPackaged directly inside getProcesses function --- src/main/events/library/close-game.ts | 3 +-- src/main/helpers/ps.ts | 5 +++-- src/main/services/process-watcher.ts | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/main/events/library/close-game.ts b/src/main/events/library/close-game.ts index 586253b9..0d556925 100644 --- a/src/main/events/library/close-game.ts +++ b/src/main/events/library/close-game.ts @@ -4,13 +4,12 @@ import { gameRepository } from "@main/repository"; import { registerEvent } from "../register-event"; import { getProcesses } from "@main/helpers"; -import { app } from "electron"; const closeGame = async ( _event: Electron.IpcMainInvokeEvent, gameId: number ) => { - const processes = await getProcesses(app.isPackaged); + const processes = await getProcesses(); const game = await gameRepository.findOne({ where: { id: gameId } }); const gameProcess = processes.find((runningProcess) => { diff --git a/src/main/helpers/ps.ts b/src/main/helpers/ps.ts index 3d83cc7d..dbc11f09 100644 --- a/src/main/helpers/ps.ts +++ b/src/main/helpers/ps.ts @@ -2,13 +2,14 @@ import psList from "ps-list"; import path from "node:path"; import childProcess from "node:child_process"; import { promisify } from "node:util"; +import { app } from "electron"; const TEN_MEGABYTES = 1000 * 1000 * 10; const execFile = promisify(childProcess.execFile); -export const getProcesses = async (isPackaged: boolean) => { +export const getProcesses = async () => { if (process.platform == "win32") { - const binaryPath = isPackaged + const binaryPath = app.isPackaged ? path.join(process.resourcesPath, "dist", "fastlist.exe") : path.join(__dirname, "..", "..", "resources", "dist", "fastlist.exe"); diff --git a/src/main/services/process-watcher.ts b/src/main/services/process-watcher.ts index 0668c1db..0d699165 100644 --- a/src/main/services/process-watcher.ts +++ b/src/main/services/process-watcher.ts @@ -4,7 +4,6 @@ import { IsNull, Not } from "typeorm"; import { gameRepository } from "@main/repository"; import { getProcesses } from "@main/helpers"; import { WindowManager } from "./window-manager"; -import { app } from "electron"; const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); @@ -26,7 +25,7 @@ export const startProcessWatcher = async () => { continue; } - const processes = await getProcesses(app.isPackaged); + const processes = await getProcesses(); for (const game of games) { const basename = path.win32.basename(game.executablePath);