Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 39d1b55

Browse files
committed
More error scaffolding
1 parent 6405a2b commit 39d1b55

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

vscode-powershell.build.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,25 @@ task Prerequisites {
4646
function Assert-Pwsh ([Version]$RequiredPowerShellVersion) {
4747
$ErrorActionPreference = 'Continue'
4848
try {
49-
[Version]$pwshVersion = (Get-Command -Name pwsh -CommandType Application -ErrorAction Stop)
49+
$pwsh = (Get-Command -Name pwsh -CommandType Application -ErrorAction Stop)
5050
| Sort-Object Version -Descending
5151
| Select-Object -First 1
52-
| ForEach-Object Version
52+
if (-not $pwsh) {
53+
throw [NotImplementedException]'Pwsh not found but automatic installation is not yet supported.'
54+
}
55+
[Version]$pwshVersion = $pwsh.Version
5356
} catch {
5457
if ($InstallPrerequisites) {
5558
throw [NotImplementedException]"Pwsh not found but automatic installation is not yet supported. Error: $PSItem"
5659
}
57-
Write-Error "PowerShell (pwsh) not found on your system. Please install PowerShell $RequiredPowerShellVersion or higher and ensure it is available in your `$env:PATH environment variable"
60+
Write-Error "PowerShell (pwsh) not found on your system. Please install PowerShell $RequiredPowerShellVersion or higher and ensure it is available in your `$env:PATH environment variable. $PSItem"
5861
return
5962
}
6063
if ($pwshVersion -lt $RequiredPowerShellVersion) {
6164
if ($InstallPrerequisites) {
6265
throw [NotImplementedException]"Pwsh $pwshVersion less than $requiredPowershell Version but Automatic installation of Pwsh is not yet supported."
6366
}
64-
Write-Error "PowerShell version $pwshVersion is not or no longer supported. Please install PowerShell $RequiredPowerShellVersion or higher"
67+
Write-Error "PowerShell version $pwshVersion is not or no longer supported. Please install PowerShell $RequiredPowerShellVersion or higher. $PSItem"
6568
return
6669
}
6770
Write-Debug "PREREQUISITE: Detected supported PowerShell version $pwshVersion at or above minimum $RequiredPowerShellVersion"

0 commit comments

Comments
 (0)