Skip to content

Commit 7f5114b

Browse files
StartAutomatingStartAutomating
authored andcommitted
Consolidate Aspects - Returning unmodified ScriptBlock when nothing to consolidate (re #413)
1 parent 3897ce2 commit 7f5114b

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Commands/Optimization/Optimizer-ConsolidateAspects.ps1

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function PipeScript.Optimizer.ConsolidateAspects {
106106
}
107107
})
108108
$uniquePotentialNames = $potentialNames | Select-Object -Unique
109-
if ($uniquePotentialNames -and
110-
$uniquePotentialNames -isnot [Object[]]) {
109+
if ($uniquePotentialNames -and
110+
$uniquePotentialNames -isnot [Object[]]) {
111111
$consolidations[$k] = $uniquePotentialNames
112112
}
113113
}
@@ -121,7 +121,12 @@ function PipeScript.Optimizer.ConsolidateAspects {
121121
"`$$($consolidate.Value) = $($consolidate.Key)"
122122
}
123123
) -join [Environment]::NewLine)")
124-
# Update-PipeScript -RegexReplacement $regexReplacements -ScriptBlock $ScriptBlock -Prepend $prepend
124+
if ($consolidations.Count) {
125+
Update-PipeScript -RegexReplacement $regexReplacements -ScriptBlock $ScriptBlock -Prepend $prepend
126+
}
127+
else {
128+
$ScriptBlock
129+
}
125130
}
126131
}
127132

0 commit comments

Comments
 (0)