From 2a244245de33f480b73e221674836e54ebb08f62 Mon Sep 17 00:00:00 2001 From: Administrator Date: Tue, 10 Mar 2026 02:32:48 +0100 Subject: [PATCH] feat: add afterPack icon patching script --- scripts/afterPack.cjs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 scripts/afterPack.cjs diff --git a/scripts/afterPack.cjs b/scripts/afterPack.cjs new file mode 100644 index 0000000..11f44a1 --- /dev/null +++ b/scripts/afterPack.cjs @@ -0,0 +1,32 @@ +const path = require("path"); + +module.exports = async function afterPack(context) { + let rcedit; + try { + rcedit = require("rcedit").rcedit; + } catch { + console.warn(" rcedit: skipped - rcedit not installed"); + return; + } + + const productFilename = context.packager?.appInfo?.productFilename; + if (!productFilename) { + console.warn(" rcedit: skipped - productFilename not available"); + return; + } + + const exePath = path.join(context.appOutDir, `${productFilename}.exe`); + const iconPath = path.resolve(__dirname, "..", "assets", "app_icon.ico"); + + try { + const fs = require("fs"); + if (!fs.existsSync(iconPath)) { + console.warn(" rcedit: skipped - app_icon.ico not found"); + return; + } + console.log(` rcedit: patching icon -> ${exePath}`); + await rcedit(exePath, { icon: iconPath }); + } catch (error) { + console.warn(` rcedit: failed - ${String(error)}`); + } +};