Skip to content

Invoke-UpdateCheck fixes #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions UpdateCheck.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,18 @@ function Invoke-UpdateCheck

The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub

.PARAMETER Force
For debugging purposes, using this switch will allow the check to occur more than the limit
of once per day. This _will not_ bypass the DisableUpdateCheck configuration value however.

.EXAMPLE
Invoke-UpdateCheck

.NOTES
Internal-only helper method.
#>
param()
[cmdletbinding()]
param([switch] $Force)

if (Get-GitHubConfiguration -Name DisableUpdateCheck)
{
Expand All @@ -44,6 +49,18 @@ function Invoke-UpdateCheck

$jobNameToday = "Invoke-UpdateCheck-" + (Get-Date -format 'yyyyMMdd')

if ($Force)
{
if ($null -ne $script:UpdateCheckJobName)
{
# We're going to clear out the existing job and try running it again.
$null = Receive-Job -Name $script:UpdateCheckJobName -AutoRemoveJob -Wait -ErrorAction SilentlyContinue -ErrorVariable errorInfo
}

$script:UpdateCheckJobName = $null
$script:HasLatestVersion = $null
}

# We only check once per day
if ($jobNameToday -eq $script:UpdateCheckJobName)
{
Expand Down Expand Up @@ -83,7 +100,7 @@ function Invoke-UpdateCheck
if ($script:HasLatestVersion)
{
$message = "[$moduleName] update check complete. Running latest version: $latestVersion"
Write-Log =Message $message -Level Verbose
Write-Log -Message $message -Level Verbose
}
elseif ($moduleVersion -gt $latestVersion)
{
Expand Down Expand Up @@ -132,6 +149,9 @@ function Invoke-UpdateCheck

try
{
# Disable Progress Bar in function scope during Invoke-WebRequest
$ProgressPreference = 'SilentlyContinue'

Invoke-WebRequest @params
}
catch
Expand Down