Skip to content

Commit

Permalink
use app.isPackaged directly inside getProcesses function
Browse files Browse the repository at this point in the history
  • Loading branch information
Zamitto committed Apr 27, 2024
1 parent bf218e9 commit 3177213
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/main/events/library/close-game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 3 additions & 2 deletions src/main/helpers/ps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
3 changes: 1 addition & 2 deletions src/main/services/process-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand All @@ -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);
Expand Down

0 comments on commit 3177213

Please sign in to comment.