From f2fd951b83019364f7e84e1544c3ad2b437dbd12 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Thu, 5 May 2022 21:48:04 +0200 Subject: [PATCH 1/2] Mods upgrade/install only if upgrade/install OK --- Winget-AutoUpdate/functions/Update-App.ps1 | 29 +++++++++++----------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 1d89c48..96162cc 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -16,34 +16,35 @@ Function Update-App ($app) { #Run Winget Upgrade command & $Winget upgrade --id $($app.Id) --all --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - #Check if mods exist - $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) - - if ($ModsUpgrade){ - Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" - & "$ModsUpgrade" - } - #Check if application updated properly $CheckOutdated = Get-WingetOutdatedApps $FailedToUpgrade = $false + #Check if mods exist + $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) foreach ($CheckApp in $CheckOutdated){ if ($($CheckApp.Id) -eq $($app.Id)) { #If app failed to upgrade, run Install command & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append - - if ($ModsInstall){ - Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" - & "$ModsInstall" - } #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps foreach ($CheckApp2 in $CheckOutdated2){ if ($($CheckApp2.Id) -eq $($app.Id)) { $FailedToUpgrade = $true - } + } + else { + if ($ModsInstall){ + Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" + & "$ModsInstall" + } + } + } + } + else { + if ($ModsUpgrade){ + Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" + & "$ModsUpgrade" } } } From 4740a87e6c78df99acd1f715d5b0e8dff9c97190 Mon Sep 17 00:00:00 2001 From: KnifMelti Date: Fri, 6 May 2022 02:47:45 +0200 Subject: [PATCH 2/2] After upgrade/install text not during --- Winget-AutoUpdate/functions/Update-App.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index 96162cc..378f4c2 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -35,7 +35,7 @@ Function Update-App ($app) { } else { if ($ModsInstall){ - Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" + Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow" & "$ModsInstall" } } @@ -43,7 +43,7 @@ Function Update-App ($app) { } else { if ($ModsUpgrade){ - Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow" + Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" & "$ModsUpgrade" } }