Skip to content

Commit d32bd11

Browse files
Invoke-UpdateCheck fixes (#252)
* Fixes a regression [introduced by #242 unfortunately](17f6122#diff-34a614678760cc83c5a91ad95ae240e5R86) when I was reducing the lines in the module that exceeded 100 chars. Specifically (note the `=Message` instead of the `-Message`): https://github.com/microsoft/PowerShellForGitHub/blob/17f6122d7812ee4001ce4bdf630429e711e45f7b/UpdateCheck.ps1#L86 * Updates the web request to suppress the progress bar using `$ProgressPreference = 'SilentlyContinue'` * Adds a `-Force` switch to force the update check to happen again to make future debugging scenarios easier. Fixes #249 Fixes #250
1 parent eedfaa3 commit d32bd11

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

UpdateCheck.ps1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,18 @@ function Invoke-UpdateCheck
2626
2727
The Git repo for this module can be found here: http://aka.ms/PowerShellForGitHub
2828
29+
.PARAMETER Force
30+
For debugging purposes, using this switch will allow the check to occur more than the limit
31+
of once per day. This _will not_ bypass the DisableUpdateCheck configuration value however.
32+
2933
.EXAMPLE
3034
Invoke-UpdateCheck
3135
3236
.NOTES
3337
Internal-only helper method.
3438
#>
35-
param()
39+
[cmdletbinding()]
40+
param([switch] $Force)
3641

3742
if (Get-GitHubConfiguration -Name DisableUpdateCheck)
3843
{
@@ -44,6 +49,18 @@ function Invoke-UpdateCheck
4449

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

52+
if ($Force)
53+
{
54+
if ($null -ne $script:UpdateCheckJobName)
55+
{
56+
# We're going to clear out the existing job and try running it again.
57+
$null = Receive-Job -Name $script:UpdateCheckJobName -AutoRemoveJob -Wait -ErrorAction SilentlyContinue -ErrorVariable errorInfo
58+
}
59+
60+
$script:UpdateCheckJobName = $null
61+
$script:HasLatestVersion = $null
62+
}
63+
4764
# We only check once per day
4865
if ($jobNameToday -eq $script:UpdateCheckJobName)
4966
{
@@ -83,7 +100,7 @@ function Invoke-UpdateCheck
83100
if ($script:HasLatestVersion)
84101
{
85102
$message = "[$moduleName] update check complete. Running latest version: $latestVersion"
86-
Write-Log =Message $message -Level Verbose
103+
Write-Log -Message $message -Level Verbose
87104
}
88105
elseif ($moduleVersion -gt $latestVersion)
89106
{
@@ -132,6 +149,9 @@ function Invoke-UpdateCheck
132149

133150
try
134151
{
152+
# Disable Progress Bar in function scope during Invoke-WebRequest
153+
$ProgressPreference = 'SilentlyContinue'
154+
135155
Invoke-WebRequest @params
136156
}
137157
catch

0 commit comments

Comments
 (0)