From 33e237948e72db0ea970e3f21fea78afb7253929 Mon Sep 17 00:00:00 2001 From: AnRil Date: Mon, 18 May 2026 15:25:04 +0700 Subject: [PATCH] fix(release): write package.json as UTF-8 without BOM PS5.1 Get-Content -Raw without -Encoding utf8 reads in CP1251, mangling non-ASCII like em-dash. Set-Content -Encoding utf8 writes a BOM that breaks PostCSS / electron-builder reads of package.json. Use .NET ReadAllText/WriteAllText with UTF8Encoding(false) to guarantee roundtrip-safe UTF-8 without BOM. Co-Authored-By: Claude Opus 4.7 --- scripts/release.ps1 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scripts/release.ps1 b/scripts/release.ps1 index c6b4b2a..5c7dbb2 100644 --- a/scripts/release.ps1 +++ b/scripts/release.ps1 @@ -106,9 +106,15 @@ if ($DryRun) { } # --- Bump package.json -------------------------------------------------- +# IMPORTANT: read+write as UTF-8 WITHOUT BOM. PS5.1 defaults will (a) read the +# file as CP1251 and mangle non-ASCII chars like em-dash, and (b) write back +# with a BOM that breaks PostCSS / electron-builder reads of package.json. Write-Host "Bumping package.json to $next..." -ForegroundColor Cyan -$pkgJson = (Get-Content package.json -Raw) -replace "`"version`":\s*`"$current`"", "`"version`": `"$next`"" -Set-Content -Path package.json -Value $pkgJson -NoNewline -Encoding utf8 +$pkgPath = Join-Path $root 'package.json' +$utf8NoBom = New-Object System.Text.UTF8Encoding $false +$pkgJson = [System.IO.File]::ReadAllText($pkgPath, $utf8NoBom) +$pkgJson = $pkgJson -replace "`"version`":\s*`"$current`"", "`"version`": `"$next`"" +[System.IO.File]::WriteAllText($pkgPath, $pkgJson, $utf8NoBom) git add package.json git commit -m "chore(release): $tag"