diff --git a/scripts/Windows/Scripts/Hooks.ps1 b/scripts/Windows/Scripts/Hooks.ps1 new file mode 100644 index 00000000..78843f83 --- /dev/null +++ b/scripts/Windows/Scripts/Hooks.ps1 @@ -0,0 +1,26 @@ +function Invoke-Hook() { + param( + [string] $Name, + [System.Action] $Fallback + ) + + if ($Fallback) { + $scriptBlock = { $Fallback.Invoke(); }; + } else { + $scriptBlock = { }; + } + + if (Get-Command "$Name" -ErrorAction SilentlyContinue) { + $parameters = { + fallback = $scriptBlock + }; + + Write-Host "Running Hook ``$Name``"; + & "$Name" @parameters; + } elseif ($Fallback) { + Write-Host "Running Default of Hook ``$Name``"; + & $scriptBlock; + } else { + Write-Host "Hook ``$Name``"; + } +}