Skip to content

Commit

Permalink
Nuke the PSGallery checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Thom Neale committed Jan 3, 2025
1 parent 8230ca2 commit 30ec25d
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions PowerShell/ScubaGear/CheckVersion.ps1
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
function Invoke-CheckScubaGearVersion {
<#
.SYNOPSIS
Complain if a newer version of ScubaGear is available on PSGallery.
.DESCRIPTION
Checks PSGallery latest version and compares it to the latest version installed
from PSGallery.
#>

# Retrieve the installed version of ScubaGear from the system
$InstalledModule = Get-Module -Name ScubaGear -ListAvailable -ErrorAction 'Stop'

# If multiple different versions are installed, get the most recent.
if ($InstalledModule -is [array]) {
$InstalledModule = $InstalledModule | Sort-Object -Property Version | Select-Object -Last 1
}

# Check if no results found.
if (!$InstalledModule) {
# If we are here, ScubaGear is not installed from PSGallery.
# Or it may have been installed a different way in a nonstandard folder,
# or is running in an extracted release folder. Check github instead.
return Invoke-CheckScubaGearVersionGithub -ErrorAction 'Stop'
}

$LatestInstalledVersion = [System.Version]$InstalledModule.Version

# Retrieve the latest version from PowerShell Gallery
$ModuleInfo = Find-Module -Name ScubaGear -ErrorAction 'Stop'
$LatestPSGalleryVersion = [System.Version]$ModuleInfo.Version

if ($LatestInstalledVersion -lt $LatestPSGalleryVersion) {
Write-Warning "A newer version of ScubaGear ($LatestPSGalleryVersion) is available on PowerShell Gallery. This notification can be disabled by setting `$env:SCUBAGEAR_SKIP_VERSION_CHECK = `$true before running ScubaGear."
}
}


function Invoke-CheckScubaGearVersionGithub {
function Invoke-CheckScubaGearVersion {
<#
.SYNOPSIS
Complain if a newer version of ScubaGear is available from the Github release page.
Expand Down

0 comments on commit 30ec25d

Please sign in to comment.