diff --git a/Winget-AutoUpdate-Install.ps1 b/Winget-AutoUpdate-Install.ps1 index 301d4dd..078ba13 100644 --- a/Winget-AutoUpdate-Install.ps1 +++ b/Winget-AutoUpdate-Install.ps1 @@ -111,6 +111,8 @@ function Install-WingetAutoUpdate{ New-Item -ItemType Directory -Force -Path $WingetUpdatePath } Copy-Item -Path "$PSScriptRoot\Winget-AutoUpdate\*" -Destination $WingetUpdatePath -Recurse -Force -ErrorAction SilentlyContinue + #Add 'mods' directory + New-Item -ItemType Directory -Force -Path "$WingetUpdatePath\mods" #White List or Black List apps if ($UseWhiteList){ diff --git a/Winget-AutoUpdate/functions/Test-Mods.ps1 b/Winget-AutoUpdate/functions/Test-Mods.ps1 new file mode 100644 index 0000000..dba00a1 --- /dev/null +++ b/Winget-AutoUpdate/functions/Test-Mods.ps1 @@ -0,0 +1,18 @@ +#Function to check if modification exists in 'mods' directory + +function Test-Mods ($app){ + + if (Test-Path "$WorkingDir\mods\$app-install.ps1"){ + $ModsInstall = "$WorkingDir\mods\$app-install.ps1" + $ModsUpgrade = "$WorkingDir\mods\$app-install.ps1" + } + if (Test-Path "$WorkingDir\mods\$app-upgrade.ps1"){ + $ModsUpgrade = "$WorkingDir\mods\$app-upgrade.ps1" + } + else{ + return 0 + } + + return $ModsInstall,$ModsUpgrade + +} \ No newline at end of file diff --git a/Winget-AutoUpdate/functions/Update-App.ps1 b/Winget-AutoUpdate/functions/Update-App.ps1 index c11920d..d013345 100644 --- a/Winget-AutoUpdate/functions/Update-App.ps1 +++ b/Winget-AutoUpdate/functions/Update-App.ps1 @@ -16,6 +16,13 @@ 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 + $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 @@ -24,6 +31,13 @@ Function Update-App ($app) { #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 + + #Check if mods exist + $ModsInstall = Test-Mods $($app.Id) + if ($ModsInstall){ + Write-Log "Modifications for $($app.Id) during install are being applied..." "Yellow" + & "$ModsInstall" + } #Check if application installed properly $CheckOutdated2 = Get-WingetOutdatedApps diff --git a/Winget-AutoUpdate/functions/Update-WAU.ps1 b/Winget-AutoUpdate/functions/Update-WAU.ps1 index c46c9d2..74b7018 100644 --- a/Winget-AutoUpdate/functions/Update-WAU.ps1 +++ b/Winget-AutoUpdate/functions/Update-WAU.ps1 @@ -31,6 +31,10 @@ function Update-WAU { $TempPath = (Resolve-Path "$location\*\Winget-AutoUpdate\")[0].Path if ($TempPath){ Copy-Item -Path "$TempPath\*" -Destination "$WorkingDir\" -Exclude "icons" -Recurse -Force + #Add 'mods' directory + if (!(Test-Path "$WorkingDir\mods")){ + New-Item -ItemType Directory -Force -Path "$WingetUpdatePath\mods" + } } #Remove update zip file and update temp folder