fix(ci): BOM 守卫步骤改用 shell: powershell(cmd 套 -Command 多行引号会全乱)

第一轮 CI 暴露:该步骤自身写法错,不是脚本错。shell: cmd + powershell -Command "..."
带多行/内层引号,经 cmd 转义后变成:
  Missing closing '}' / '$errs' is not recognized / -and was unexpected
全是指 step 自身,与被测 .ps1 无关。

修正:直接用 shell: powershell(runner 上的 powershell 就是 5.1,正是要测的目标)+ run: | 块,
与旁边已通过的 install 冒烟步骤同一形态。
This commit is contained in:
jkooe committed 2026-10-07 02:04:43 +08:00
1 parent 25f889c6d8
commit 817ec3645b
1 file changed
+11 -9
+11 -9
View File
@@ -64,17 +64,19 @@ jobs:
# 整份脚本 ParseError(真机 2026-10-04 踩过:install.ps1 报「","后面缺少表达式」)。
# 之前的冒烟全用 pwsh(7+ 认无 BOM UTF-8),所以 CI 绿、真机炸。
# 这里只做「解析 + 首行 help」检查:5.1 能否读懂,就是真机的核心约束。
# ⚠️ 必须用 shell: powershell(runner 上的 powershell 即 Windows PowerShell 5.1)。
# 不要用 shell: cmd 再套 powershell -Command "..." —— 多行带引号经 cmd 转义会全乱
# (实测:Missing closing '}' / '$errs' is not recognized,是步骤自身坏,不是脚本坏)。
- name: 冒烟 — 脚本可被 Windows PowerShell 5.1 解析(BOM 守卫)
shell: cmd
run: >
powershell -NoProfile -ExecutionPolicy Bypass -Command "
$ErrorActionPreference='Stop';
foreach ($f in @('scripts\install.ps1','scripts\uninstall.ps1','scripts\rescue-network.ps1')) {
$errs = $null;
[void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f).Path, [ref]$null, [ref]$errs);
shell: powershell
run: |
$ErrorActionPreference = 'Stop'
foreach ($f in @('scripts\install.ps1', 'scripts\uninstall.ps1', 'scripts\rescue-network.ps1')) {
$errs = $null
[void][System.Management.Automation.Language.Parser]::ParseFile((Resolve-Path $f).Path, [ref]$null, [ref]$errs)
if ($errs -and $errs.Count -gt 0) { throw ('5.1 解析失败 ' + $f + ' -> ' + $errs[0].Message) }
Write-Host ('OK 5.1 parse: ' + $f);
}"
Write-Host ('OK 5.1 parse: ' + $f)
}
- name: 冒烟 — install.ps1 安装链路
shell: powershell