Skip to content

Commit 1473dac

Browse files
committed
fix(cli): replace *> with 2>&1 | Out-File in install.ps1
The `*>` redirection operator on native commands can cause a .NET `InvalidOperationException` when `StandardOutputEncoding` is set but `RedirectStandardOutput` is not. This happens interactively (real console attached) but not in CI (no console). Using `2>&1 | Out-File` goes through the standard pipeline path which correctly sets both. Also adds a PowerShell 7.6 CI test job for regression coverage. Closes #1019
1 parent f1f6016 commit 1473dac

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

.github/workflows/test-standalone-install.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,99 @@ jobs:
474474
vp upgrade --rollback
475475
vp --version
476476
477+
test-install-ps1-v76:
478+
name: Test install.ps1 (Windows x64, PowerShell 7.6)
479+
runs-on: windows-latest
480+
permissions:
481+
contents: read
482+
steps:
483+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
484+
485+
- name: Install PowerShell 7.6
486+
shell: pwsh
487+
run: |
488+
dotnet tool install --global PowerShell --version 7.6.0
489+
490+
- name: Assert PowerShell 7.6.x
491+
shell: pwsh
492+
run: |
493+
$pwsh76 = "$env:USERPROFILE\.dotnet\tools\pwsh.exe"
494+
$ver = & $pwsh76 -NoProfile -Command '$PSVersionTable.PSVersion.ToString()'
495+
Write-Host "PowerShell version: $ver"
496+
if (-not $ver.StartsWith("7.6")) {
497+
Write-Error "Expected PowerShell 7.6.x but got $ver"
498+
exit 1
499+
}
500+
501+
- name: Run install.ps1 via iex (reproduces #1019)
502+
shell: pwsh
503+
run: |
504+
$pwsh76 = "$env:USERPROFILE\.dotnet\tools\pwsh.exe"
505+
& $pwsh76 -NoProfile -Command "Get-Content ./packages/cli/install.ps1 -Raw | Invoke-Expression"
506+
507+
- name: Set PATH
508+
shell: bash
509+
run: |
510+
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
511+
512+
- name: Verify installation
513+
shell: pwsh
514+
working-directory: ${{ runner.temp }}
515+
run: |
516+
$pwsh76 = "$env:USERPROFILE\.dotnet\tools\pwsh.exe"
517+
& $pwsh76 -NoProfile -Command {
518+
Write-Host "PATH: $env:Path"
519+
vp --version
520+
vp --help
521+
vp create vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
522+
cd hello
523+
vp run build
524+
vp --version
525+
}
526+
527+
- name: Verify bin setup
528+
shell: pwsh
529+
run: |
530+
$pwsh76 = "$env:USERPROFILE\.dotnet\tools\pwsh.exe"
531+
& $pwsh76 -NoProfile -Command {
532+
$binPath = "$env:USERPROFILE\.vite-plus\bin"
533+
Get-ChildItem -Force $binPath
534+
if (-not (Test-Path $binPath)) {
535+
Write-Error "Bin directory not found: $binPath"
536+
exit 1
537+
}
538+
539+
$expectedShims = @("node.exe", "npm.exe", "npx.exe")
540+
foreach ($shim in $expectedShims) {
541+
$shimFile = Join-Path $binPath $shim
542+
if (-not (Test-Path $shimFile)) {
543+
Write-Error "Shim not found: $shimFile"
544+
exit 1
545+
}
546+
Write-Host "Found shim: $shimFile"
547+
}
548+
where.exe node
549+
where.exe npm
550+
where.exe npx
551+
where.exe vp
552+
553+
$env:Path = "$env:USERPROFILE\.vite-plus\bin;$env:Path"
554+
vp env doctor
555+
vp env run --node 24 -- node -p "process.versions"
556+
}
557+
558+
- name: Verify upgrade
559+
shell: pwsh
560+
run: |
561+
$pwsh76 = "$env:USERPROFILE\.dotnet\tools\pwsh.exe"
562+
& $pwsh76 -NoProfile -Command {
563+
vp upgrade --check
564+
vp upgrade 0.1.14-alpha.1
565+
vp --version
566+
vp upgrade --rollback
567+
vp --version
568+
}
569+
477570
test-install-ps1:
478571
name: Test install.ps1 (Windows x64)
479572
runs-on: windows-latest

packages/cli/install.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ function Main {
375375
Push-Location $VersionDir
376376
try {
377377
$env:CI = "true"
378-
& "$BinDir\vp.exe" install --silent *> $installLog
378+
& "$BinDir\vp.exe" install --silent 2>&1 | Out-File $installLog
379379
if ($LASTEXITCODE -ne 0) {
380380
Write-Host "error: Failed to install dependencies. See log for details: $installLog" -ForegroundColor Red
381381
exit 1

0 commit comments

Comments
 (0)