Skip to content

Commit 0fae76f

Browse files
committed
Improve pnpm path resolution and command error handling in installation script
- a user report: [Pasted text]
1 parent f05d1a9 commit 0fae76f

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

‎install.ps1‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,15 @@ function Invoke-Step {
463463
Write-Host ""
464464

465465
if (!(Get-Command pnpm -ErrorAction SilentlyContinue)) {
466-
npm install -g pnpm *>$null
466+
if (Get-Command npm -ErrorAction SilentlyContinue) {
467+
npm install -g pnpm *>$null
468+
if (!(Get-Command pnpm -ErrorAction SilentlyContinue)) {
469+
$npmGlobalBin = npm prefix -g 2>$null
470+
if ($npmGlobalBin) {
471+
$env:PATH = "$npmGlobalBin;" + $env:PATH
472+
}
473+
}
474+
}
467475
}
468476

469477
$originalLocation = Get-Location
@@ -540,6 +548,7 @@ Set-Location $repoDir
540548

541549
$depsOk = Invoke-Step "$msg_step_deps..." {
542550
pnpm install *>$null
551+
if ($LASTEXITCODE -ne 0) { throw "pnpm install failed" }
543552
}
544553

545554
if (-not $depsOk) {
@@ -560,6 +569,7 @@ if (-not $depsOk) {
560569

561570
$null = Invoke-Step "$msg_step_deps..." {
562571
pnpm install *>$null
572+
if ($LASTEXITCODE -ne 0) { throw "pnpm install failed" }
563573
} $msg_step_deps
564574
}
565575

@@ -569,6 +579,7 @@ Remove-Item *.vsix -Force -ErrorAction SilentlyContinue
569579

570580
$null = Invoke-Step "$msg_step_build..." {
571581
pnpm run build *>$null
582+
if ($LASTEXITCODE -ne 0) { throw "pnpm run build failed" }
572583
} $msg_step_build
573584

574585
$vsixFile = Get-ChildItem *.vsix -ErrorAction SilentlyContinue | Select-Object -First 1
@@ -583,6 +594,7 @@ foreach ($i in $indices) {
583594

584595
$ok = Invoke-Step "$msg_step_install $($editor.Name)..." {
585596
& $editor.Cmd --install-extension $vsixFile.FullName --force *>$null
597+
if ($LASTEXITCODE -ne 0) { throw "Extension install failed" }
586598
}
587599

588600
if ($ok) {

0 commit comments

Comments
 (0)