Skip to content

Commit bc6dfd5

Browse files
StartAutomatingStartAutomating
authored andcommitted
CommandInfo.BlockComments - Resolving aliases (Fixes #487)
1 parent 098b55f commit bc6dfd5

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

PipeScript.types.ps1xml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,8 +1317,27 @@ if ($AllValid) {
13171317
<ScriptProperty>
13181318
<Name>BlockComments</Name>
13191319
<GetScriptBlock>
1320-
if (-not $this.ScriptBlock) {
1321-
return @()
1320+
&lt;#
1321+
.SYNOPSIS
1322+
Gets Block Comments
1323+
.DESCRIPTION
1324+
Gets Block Comments declared within a script.
1325+
#&gt;
1326+
$TargetScriptBlock = $this.ScriptBlock
1327+
if (-not $TargetScriptBlock) {
1328+
if ($this -is [Management.Automation.AliasInfo]) {
1329+
$resolveThis = $this
1330+
while ($resolveThis.ResolvedCommand) {
1331+
$resolveThis = $resolveThis.ResolvedCommand
1332+
}
1333+
if ($resolveThis.ScriptBlock) {
1334+
$TargetScriptBlock = $resolveThis.ScriptBlock
1335+
} else {
1336+
$TargetScriptBlock = ''
1337+
}
1338+
} else {
1339+
$TargetScriptBlock = ''
1340+
}
13221341
}
13231342

13241343
@([Regex]::New("
@@ -1327,7 +1346,7 @@ if ($AllValid) {
13271346
(?:.|\s)+?(?=\z|\#&gt;) # anything until the closing tag
13281347
)
13291348
\#\&gt; # the closing tag
1330-
", 'IgnoreCase,IgnorePatternWhitespace', '00:00:01').Matches($this.ScriptBlock)) -as [Text.RegularExpressions.Match[]]
1349+
", 'IgnoreCase,IgnorePatternWhitespace', '00:00:01').Matches($TargetScriptBlock)) -as [Text.RegularExpressions.Match[]]
13311350

13321351
</GetScriptBlock>
13331352
</ScriptProperty>

0 commit comments

Comments
 (0)