Adding PreInstall mods...

pull/232/head
KnifMelti 2022-11-26 17:47:38 +01:00
parent 5eb55be980
commit baa7ef84a4
2 changed files with 14 additions and 4 deletions

View File

@ -3,11 +3,15 @@
function Test-Mods ($app) { function Test-Mods ($app) {
#Takes care of a null situation #Takes care of a null situation
$ModsPreInstall = $null
$ModsInstall = $null $ModsInstall = $null
$ModsUpgrade = $null $ModsUpgrade = $null
$Mods = "$WorkingDir\mods" $Mods = "$WorkingDir\mods"
if (Test-Path "$Mods\$app-*") { if (Test-Path "$Mods\$app-*") {
if (Test-Path "$Mods\$app-preinstall.ps1") {
$ModsPreInstall = "$Mods\$app-preinstall.ps1"
}
if (Test-Path "$Mods\$app-install.ps1") { if (Test-Path "$Mods\$app-install.ps1") {
$ModsInstall = "$Mods\$app-install.ps1" $ModsInstall = "$Mods\$app-install.ps1"
$ModsUpgrade = "$Mods\$app-install.ps1" $ModsUpgrade = "$Mods\$app-install.ps1"
@ -17,6 +21,6 @@ function Test-Mods ($app) {
} }
} }
return $ModsInstall, $ModsUpgrade return $ModsPreInstall, $ModsInstall, $ModsUpgrade
} }

View File

@ -16,6 +16,15 @@ Function Update-App ($app) {
$Balise = $($app.Name) $Balise = $($app.Name)
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
$ModsPreInstall, $ModsInstall, $ModsUpgrade = Test-Mods $($app.Id)
#If PreInstall script exist
if ($ModsPreInstall) {
Write-Log "Modifications for $($app.Id) before upgrade are being applied..." "Yellow"
& "$ModsPreInstall"
}
#Winget upgrade #Winget upgrade
Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray" Write-Log "########## WINGET UPGRADE PROCESS STARTS FOR APPLICATION ID '$($App.Id)' ##########" "Gray"
@ -61,9 +70,6 @@ Function Update-App ($app) {
if ($FailedToUpgrade -eq $false) { if ($FailedToUpgrade -eq $false) {
#Check if mods exist for install/upgrade
$ModsInstall, $ModsUpgrade = Test-Mods $($app.Id)
if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) { if (($ModsUpgrade) -and ($ModsMode -eq "Upgrade")) {
Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow" Write-Log "Modifications for $($app.Id) after upgrade are being applied..." "Yellow"
& "$ModsUpgrade" & "$ModsUpgrade"