From ebda8eccc635c78966d049379837b6011a009c30 Mon Sep 17 00:00:00 2001 From: Zamitto <167933696+zamitto@users.noreply.github.com> Date: Fri, 21 Jun 2024 21:17:57 -0300 Subject: [PATCH] fix: copy vbs script to app resources --- electron-builder.yml | 4 +++- postinstall.cjs | 7 ------- src/main/events/library/create-game-shortcut.ts | 13 +++++++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/electron-builder.yml b/electron-builder.yml index 87b93940..53c67d97 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -5,7 +5,9 @@ directories: extraResources: - aria2 - seeds - - fastlist.exe + - from: node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe + to: fastlist.exe + - from: node_modules/create-desktop-shortcuts/src/windows.vbs files: - "!**/.vscode/*" - "!src/*" diff --git a/postinstall.cjs b/postinstall.cjs index 2b793257..547af988 100644 --- a/postinstall.cjs +++ b/postinstall.cjs @@ -47,11 +47,4 @@ const downloadAria2 = async () => { }); }; -if (process.platform === "win32") { - fs.copyFileSync( - "node_modules/ps-list/vendor/fastlist-0.3.0-x64.exe", - "fastlist.exe" - ); -} - downloadAria2(); diff --git a/src/main/events/library/create-game-shortcut.ts b/src/main/events/library/create-game-shortcut.ts index 17b7e42c..30dfbf7c 100644 --- a/src/main/events/library/create-game-shortcut.ts +++ b/src/main/events/library/create-game-shortcut.ts @@ -2,6 +2,8 @@ import { gameRepository } from "@main/repository"; import { registerEvent } from "../register-event"; import { IsNull, Not } from "typeorm"; import createDesktopShortcut from "create-desktop-shortcuts"; +import path from "node:path"; +import { app } from "electron"; const createGameShortcut = async ( _event: Electron.IpcMainInvokeEvent, @@ -14,10 +16,17 @@ const createGameShortcut = async ( if (game) { const filePath = game.executablePath; - const options = { filePath, name: game.title }; + const windowVbsPath = app.isPackaged + ? path.join(process.resourcesPath, "windows.vbs") + : undefined; + + const options = { + filePath, + name: game.title, + }; return createDesktopShortcut({ - windows: options, + windows: { ...options, VBScriptPath: windowVbsPath }, linux: options, osx: options, });