feat: add optional game params back

This commit is contained in:
Zamitto 2025-01-04 21:04:58 -03:00
parent 6a52cb3f52
commit b8dcd66cd2
3 changed files with 32 additions and 19 deletions

View file

@ -2,7 +2,9 @@ import { gameRepository } from "@main/repository";
import { registerEvent } from "../register-event";
import { shell } from "electron";
import { spawn } from "child_process";
import { parseExecutablePath } from "../helpers/parse-executable-path";
import { parseLaunchOptions } from "../helpers/parse-launch-options";
const openGame = async (
_event: Electron.IpcMainInvokeEvent,
@ -10,15 +12,20 @@ const openGame = async (
executablePath: string,
launchOptions: string | null
) => {
// TODO: revisit this for launchOptions
const parsedPath = parseExecutablePath(executablePath);
const parsedParams = parseLaunchOptions(launchOptions);
await gameRepository.update(
{ id: gameId },
{ executablePath: parsedPath, launchOptions }
);
shell.openPath(parsedPath);
if (parsedParams.length === 0) {
shell.openPath(parsedPath);
return;
}
spawn(parsedPath, parsedParams, { shell: false, detached: true });
};
registerEvent("openGame", openGame);