This commit is contained in:
2026-01-11 09:53:28 +01:00
parent 9c7f04d197
commit f9b9ce0994
5 changed files with 515 additions and 73 deletions

View File

@@ -19,11 +19,16 @@ if (!fs.existsSync(iconPath)) {
console.log('Patching EXE icon with rcedit...');
// Prefer local installed binary (node_modules/.bin) to avoid relying on npx.
// On Windows, npm typically creates a .cmd shim, which Node can execute.
// Prefer local installed binary to avoid relying on npx.
// Note: the `rcedit` npm package places the binary at node_modules/rcedit/bin/rcedit.exe
// and does not always create a node_modules/.bin shim.
const binDir = path.join(repoRoot, 'node_modules', '.bin');
const packageBinDir = path.join(repoRoot, 'node_modules', 'rcedit', 'bin');
const localCandidates = process.platform === 'win32'
? [
// Preferred: direct binary shipped by the package
path.join(packageBinDir, 'rcedit.exe'),
// Fallbacks: npm/yarn shim locations (if present)
path.join(binDir, 'rcedit.cmd'),
path.join(binDir, 'rcedit.exe'),
path.join(binDir, 'rcedit'),
@@ -37,8 +42,7 @@ if (localBin) {
cmd = localBin;
args = [exePath, '--set-icon', iconPath];
} else {
// Fallback to npx. Use the platform-specific shim on Windows so Node spawn finds it.
// PowerShell-only shims like npx.ps1 won't work with Node spawn; prefer npx.cmd.
// Last resort fallback to npx.
cmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
args = ['rcedit', exePath, '--set-icon', iconPath];
}