wingetautoupdate/Winget-AutoUpdate/functions/Test-Mods.ps1

51 lines
1.5 KiB
PowerShell
Raw Normal View History

# Function to check if modification exists within 'mods' directory
2022-04-20 04:22:22 +00:00
2023-09-15 14:38:54 +00:00
function Test-Mods
{
# Takes care of a null situation
[CmdletBinding()]
param
(
2023-09-15 14:38:54 +00:00
[string]
$app
)
$ModsPreInstall = $null
$ModsOverride = $null
$ModsUpgrade = $null
$ModsInstall = $null
$ModsInstalled = $null
$Mods = ('{0}\mods' -f $WorkingDir)
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-*' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-preinstall.ps1' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
$ModsPreInstall = ('{0}\{1}-preinstall.ps1' -f $Mods, $app)
}
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-override.txt' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
$ModsOverride = Get-Content -Path ('{0}\{1}-override.txt' -f $Mods, $app) -Raw
}
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-install.ps1' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
$ModsInstall = ('{0}\{1}-install.ps1' -f $Mods, $app)
$ModsUpgrade = ('{0}\{1}-install.ps1' -f $Mods, $app)
}
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-upgrade.ps1' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
$ModsUpgrade = ('{0}\{1}-upgrade.ps1' -f $Mods, $app)
}
2023-09-15 14:38:54 +00:00
if (Test-Path -Path ('{0}\{1}-installed.ps1' -f $Mods, $app) -ErrorAction SilentlyContinue)
{
$ModsInstalled = ('{0}\{1}-installed.ps1' -f $Mods, $app)
}
}
return $ModsPreInstall, $ModsOverride, $ModsUpgrade, $ModsInstall, $ModsInstalled
2022-04-20 18:54:10 +00:00
}