Skip to content

Commit 6fe2ff9

Browse files
author
James Brundage
committed
Join-PipeScript: Fixing multiple unnamed joins (Fixes #289)
1 parent 6cefc32 commit 6fe2ff9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Join-PipeScript.ps1

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,21 +388,27 @@ function Join-PipeScript
388388
if ($block.Unnamed -and -not $blockOpen) {
389389
' ' * ($block | MeasureIndent) + 'end {'
390390
$blockOpen = $true
391+
$closeEndBlock = $true
391392
}
392393
if ($StatementsToAdd) {
393394
$StatementsToAdd -join [Environment]::NewLine
394395
$StatementsToAdd = $null
395396
}
396-
$block.Extent.ToString() -replace '^end\s{0,}\{' -replace '\}$' -replace '^param\(\)[\s\r\n]{0,}'
397+
if ($block.Unnamed) {
398+
$block.Extent.ToString()
399+
} else {
400+
$block.Extent.ToString() -replace '^end\s{0,}\{' -replace '\}$' -replace '^param\(\)[\s\r\n]{0,}'
401+
}
397402
}
398403
}
399404

400405
if ($StatementsToAdd) {
401406
if ($closeEndBlock -and -not $blockOpen) {
402407
'end {'
408+
$blockOpen = $true
403409
}
404410
$StatementsToAdd -join [Environment]::NewLine
405-
$StatementsToAdd = $null
411+
$StatementsToAdd = $null
406412
}
407413

408414
# If we need to close the end block, and it is open,

0 commit comments

Comments
 (0)