From 094d36b771620ca7208e32a7778d2b4ff32c115f Mon Sep 17 00:00:00 2001 From: Kelvin Smith Date: Sat, 23 Nov 2024 18:35:42 +1300 Subject: [PATCH] Fix - Resolve issues where Scope blocks have 0 sized actions --- src/Helper.ps1 | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Helper.ps1 b/src/Helper.ps1 index d4bf2cd..fd4814f 100644 --- a/src/Helper.ps1 +++ b/src/Helper.ps1 @@ -78,20 +78,32 @@ Function Get-Action { Write-Verbose -Message ('Processing action {0}' -f $actionName) # Check if Action has any actions for the true condition if (![string]::IsNullOrEmpty($action.actions)) { - Get-Action -Actions $($action.Actions) -Parent ('{0}-True' -f $actionName) + # Make sure there are actions to be done and not an empty list + if (![string]::IsNullOrEmpty($action.Actions)) { + Get-Action -Actions $($action.Actions) -Parent ('{0}-True' -f $actionName) + } # Get the actions for the false condition - Get-Action -Actions $($action.else.Actions) -Parent ('{0}-False' -f $actionName) + # Make sure there are actions to be done and not an empty list + if (![string]::IsNullOrEmpty($action.else.Actions)) { + Get-Action -Actions $($action.else.Actions) -Parent ('{0}-False' -f $actionName) + } } } #When there is only action for the true condition else { - Get-Action -Actions $($action.Actions) -Parent ('{0}-True' -f $actionName) + # Make sure there are actions to be done and not an empty list + if (![string]::IsNullOrEmpty($action.Actions)) { + Get-Action -Actions $($action.Actions) -Parent ('{0}-True' -f $actionName) + } } } # Recursively call the function for child actions elseif ($action | Get-Member -MemberType Noteproperty -Name 'Actions') { - Get-Action -Actions $($action.Actions) -Parent $actionName + # Make sure there are actions to be done + if (![string]::IsNullOrEmpty($action.Actions)) { + Get-Action -Actions $($action.Actions) -Parent $actionName + } } } }