Skip to content

Commit 0e59f58

Browse files
authored
fix: PowerShell 5.1 compatibility for install.ps1 (#652)
- Replace 3-argument Join-Path calls with nested 2-argument calls (PS5 only supports 2 arguments) - add UTF-8 BOM to install.ps1 for PowerShell 5.1 compatibility - Add PowerShell 5.1 CI job using `shell: powershell` to prevent regressions closes voidzero-dev/vite-plus-discussions#14
1 parent 6d6721f commit 0e59f58

2 files changed

Lines changed: 79 additions & 3 deletions

File tree

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,82 @@ jobs:
178178
# cd hello && vp run build
179179
"
180180
181+
test-install-ps1-v5:
182+
name: Test install.ps1 (Windows x64, PowerShell 5.1)
183+
runs-on: windows-latest
184+
permissions:
185+
contents: read
186+
steps:
187+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
188+
189+
- name: Assert PowerShell 5.x
190+
shell: powershell
191+
run: |
192+
Write-Host "PowerShell version: $($PSVersionTable.PSVersion)"
193+
if ($PSVersionTable.PSVersion.Major -ne 5) {
194+
Write-Error "Expected PowerShell 5.x but got $($PSVersionTable.PSVersion)"
195+
exit 1
196+
}
197+
198+
- name: Run install.ps1
199+
shell: powershell
200+
run: |
201+
& ./packages/cli/install.ps1
202+
203+
- name: Set PATH
204+
shell: bash
205+
run: |
206+
echo "$USERPROFILE\.vite-plus\bin" >> $GITHUB_PATH
207+
208+
- name: Verify installation
209+
shell: powershell
210+
working-directory: ${{ runner.temp }}
211+
run: |
212+
Write-Host "PATH: $env:Path"
213+
vp --version
214+
vp --help
215+
vp create vite --no-interactive --no-agent -- hello --no-interactive -t vanilla
216+
cd hello
217+
vp run build
218+
vp --version
219+
220+
- name: Verify bin setup
221+
shell: powershell
222+
run: |
223+
$binPath = "$env:USERPROFILE\.vite-plus\bin"
224+
Get-ChildItem -Force $binPath
225+
if (-not (Test-Path $binPath)) {
226+
Write-Error "Bin directory not found: $binPath"
227+
exit 1
228+
}
229+
230+
$expectedShims = @("node.cmd", "npm.cmd", "npx.cmd")
231+
foreach ($shim in $expectedShims) {
232+
$shimFile = Join-Path $binPath $shim
233+
if (-not (Test-Path $shimFile)) {
234+
Write-Error "Shim not found: $shimFile"
235+
exit 1
236+
}
237+
Write-Host "Found shim: $shimFile"
238+
}
239+
where.exe node
240+
where.exe npm
241+
where.exe npx
242+
where.exe vp
243+
244+
$env:Path = "$env:USERPROFILE\.vite-plus\bin;$env:Path"
245+
vp env doctor
246+
vp env run --node 24 -- node -p "process.versions"
247+
248+
- name: Verify upgrade
249+
shell: powershell
250+
run: |
251+
vp upgrade --check
252+
vp upgrade 0.0.0-f74442ad.20260222-0755
253+
vp --version
254+
vp upgrade --rollback
255+
vp --version
256+
181257
test-install-ps1:
182258
name: Test install.ps1 (Windows x64)
183259
runs-on: windows-latest

packages/cli/install.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Vite+ CLI Installer for Windows
1+
# Vite+ CLI Installer for Windows
22
# https://viteplus.dev/install.ps1
33
#
44
# Usage:
@@ -131,7 +131,7 @@ function Download-AndExtract {
131131
& "$env:SystemRoot\System32\tar.exe" -xzf $tempFile -C $tempExtract
132132

133133
# Copy the specified file/directory
134-
$sourcePath = Join-Path $tempExtract "package" $Filter
134+
$sourcePath = Join-Path (Join-Path $tempExtract "package") $Filter
135135
if (Test-Path $sourcePath) {
136136
Copy-Item -Path $sourcePath -Destination $DestDir -Recurse -Force
137137
}
@@ -293,7 +293,7 @@ function Main {
293293
& "$env:SystemRoot\System32\tar.exe" -xzf $platformTempFile -C $platformTempExtract
294294

295295
# Copy binary to BinDir
296-
$binarySource = Join-Path $platformTempExtract "package" $binaryName
296+
$binarySource = Join-Path (Join-Path $platformTempExtract "package") $binaryName
297297
if (Test-Path $binarySource) {
298298
Copy-Item -Path $binarySource -Destination $BinDir -Force
299299
}

0 commit comments

Comments
 (0)