$ModsInstall/$ModsInstalled

pull/232/head
KnifMelti 2022-12-04 01:55:40 +01:00
parent e5b8112023
commit 9e2573eaea
2 changed files with 17 additions and 14 deletions

View File

@ -4,8 +4,9 @@ function Test-Mods ($app) {
#Takes care of a null situation #Takes care of a null situation
$ModsPreInstall = $null $ModsPreInstall = $null
$ModsInstall = $null
$ModsUpgrade = $null $ModsUpgrade = $null
$ModsInstall = $null
$ModsInstalled = $null
$Mods = "$WorkingDir\mods" $Mods = "$WorkingDir\mods"
if (Test-Path "$Mods\$app-*") { if (Test-Path "$Mods\$app-*") {
@ -19,8 +20,11 @@ function Test-Mods ($app) {
if (Test-Path "$Mods\$app-upgrade.ps1") { if (Test-Path "$Mods\$app-upgrade.ps1") {
$ModsUpgrade = "$Mods\$app-upgrade.ps1" $ModsUpgrade = "$Mods\$app-upgrade.ps1"
} }
if (Test-Path "$Mods\$app-installed.ps1") {
$ModsInstalled = "$Mods\$app-installed.ps1"
}
} }
return $ModsPreInstall, $ModsInstall, $ModsUpgrade return $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled
} }

View File

@ -17,7 +17,7 @@ Function Update-App ($app) {
Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text Start-NotifTask -Title $Title -Message $Message -MessageType $MessageType -Balise $Balise -Button1Action $ReleaseNoteURL -Button1Text $Button1Text
#Check if mods exist for preinstall/install/upgrade #Check if mods exist for preinstall/install/upgrade
$ModsPreInstall, $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id) $ModsPreInstall, $ModsUpgrade, $ModsInstall, $ModsInstalled = Test-Mods $($app.Id)
#If PreInstall script exist #If PreInstall script exist
if ($ModsPreInstall) { if ($ModsPreInstall) {
@ -32,8 +32,10 @@ Function Update-App ($app) {
Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" Write-Log "-> Running: Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $Winget upgrade --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Set mods to apply as an upgrade if ($ModsUpgrade) {
$ModsMode = "Upgrade" Write-Log "Modifications for $($app.Id) during upgrade are being applied..." "Yellow"
& "$ModsUpgrade"
}
#Check if application updated properly #Check if application updated properly
$CheckOutdated = Get-WingetOutdatedApps $CheckOutdated = Get-WingetOutdatedApps
@ -55,8 +57,10 @@ Function Update-App ($app) {
Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h" Write-Log "-> Running: Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h"
& $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append & $Winget install --id $($app.Id) --accept-package-agreements --accept-source-agreements -h | Tee-Object -file $LogFile -Append
#Set mods to apply as an install if ($ModsInstall) {
$ModsMode = "Install" Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow"
& "$ModsInstall"
}
#Check if application installed properly #Check if application installed properly
$CheckOutdated2 = Get-WingetOutdatedApps $CheckOutdated2 = Get-WingetOutdatedApps
@ -69,13 +73,8 @@ Function Update-App ($app) {
} }
if ($FailedToUpgrade -eq $false) { if ($FailedToUpgrade -eq $false) {
if ($ModsInstalled) {
if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) { Write-Log "Modifications for $($app.Id) after upgrade/install are being applied..." "Yellow"
Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow"
& "$ModsUpgrade"
}
elseif (($ModsInstall) -and ($ModsMode -eq "Install")) {
Write-Log "Modifications for $($app.Id) after install are being applied..." "Yellow"
& "$ModsInstall" & "$ModsInstall"
} }
} }