Check if PSReadline is installed first

This commit is contained in:
Anthony Rose 2024-04-17 11:07:02 +01:00
parent 0599cd96f1
commit bf49b460d8

View file

@ -87,7 +87,7 @@ Remove-Variable -Name nvim
$OutputEncoding = [System.Text.Encoding]::UTF8 $OutputEncoding = [System.Text.Encoding]::UTF8
# Try upgrading the default version of PSReadLine to something newer. # Try upgrading the default version of PSReadLine to something newer.
if ((Get-Module PSReadline).Version -le [Version]"2.0.0.0") { if ($null -ne (Get-Module PSReadline).Version -and (Get-Module PSReadline).Version -le [Version]"2.0.0.0") {
try { try {
Write-Host "PSReadLine <= 2.0.0.0. Trying to upgrade..." Write-Host "PSReadLine <= 2.0.0.0. Trying to upgrade..."
Install-Module -Scope CurrentUser -Name PSReadLine -Force -ErrorAction SilentlyContinue Install-Module -Scope CurrentUser -Name PSReadLine -Force -ErrorAction SilentlyContinue