Skip to content

Commit 098b55f

Browse files
author
James Brundage
committed
CommandInfo.BlockComments - Resolving aliases (Fixes #487)
1 parent bce937a commit 098b55f

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
1-
if (-not $this.ScriptBlock) {
2-
return @()
1+
<#
2+
.SYNOPSIS
3+
Gets Block Comments
4+
.DESCRIPTION
5+
Gets Block Comments declared within a script.
6+
#>
7+
$TargetScriptBlock = $this.ScriptBlock
8+
if (-not $TargetScriptBlock) {
9+
if ($this -is [Management.Automation.AliasInfo]) {
10+
$resolveThis = $this
11+
while ($resolveThis.ResolvedCommand) {
12+
$resolveThis = $resolveThis.ResolvedCommand
13+
}
14+
if ($resolveThis.ScriptBlock) {
15+
$TargetScriptBlock = $resolveThis.ScriptBlock
16+
} else {
17+
$TargetScriptBlock = ''
18+
}
19+
} else {
20+
$TargetScriptBlock = ''
21+
}
322
}
423

524
@([Regex]::New("
@@ -8,4 +27,4 @@ if (-not $this.ScriptBlock) {
827
(?:.|\s)+?(?=\z|\#>) # anything until the closing tag
928
)
1029
\#\> # the closing tag
11-
", 'IgnoreCase,IgnorePatternWhitespace', '00:00:01').Matches($this.ScriptBlock)) -as [Text.RegularExpressions.Match[]]
30+
", 'IgnoreCase,IgnorePatternWhitespace', '00:00:01').Matches($TargetScriptBlock)) -as [Text.RegularExpressions.Match[]]

0 commit comments

Comments
 (0)