File tree Expand file tree Collapse file tree 3 files changed +53
-4
lines changed Expand file tree Collapse file tree 3 files changed +53
-4
lines changed Original file line number Diff line number Diff line change @@ -127,15 +127,15 @@ internal static bool TryParseScriptFileContents(
127127 {
128128 string line = fileContents [ i ] ;
129129
130- if ( line . StartsWith ( "<#PSScriptInfo" ) )
130+ if ( line . Trim ( ) . StartsWith ( "<#PSScriptInfo" ) )
131131 {
132132 int j = i + 1 ; // start at the next line
133133 // keep grabbing lines until we get to closing #>
134134 while ( j < fileContents . Length )
135135 {
136136 string blockLine = fileContents [ j ] ;
137137 psScriptInfoCommentContent . Add ( blockLine ) ;
138- if ( blockLine . StartsWith ( "#>" ) )
138+ if ( blockLine . Trim ( ) . StartsWith ( "#>" ) )
139139 {
140140
141141 reachedPSScriptInfoCommentEnd = true ;
@@ -157,7 +157,7 @@ internal static bool TryParseScriptFileContents(
157157 return false ;
158158 }
159159 }
160- else if ( line . StartsWith ( "<#" ) )
160+ else if ( line . Trim ( ) . StartsWith ( "<#" ) )
161161 {
162162 // The next comment block must be the help comment block (containing description)
163163 // keep grabbing lines until we get to closing #>
@@ -166,7 +166,7 @@ internal static bool TryParseScriptFileContents(
166166 {
167167 string blockLine = fileContents [ j ] ;
168168
169- if ( blockLine . StartsWith ( "#>" ) )
169+ if ( blockLine . Trim ( ) . StartsWith ( "#>" ) )
170170 {
171171 reachedHelpInfoCommentEnd = true ;
172172 i = j + 1 ;
Original file line number Diff line number Diff line change @@ -88,4 +88,11 @@ Describe "Test Test-PSScriptFileInfo" -tags 'CI' {
8888
8989 Test-PSScriptFileInfo $scriptFilePath | Should - Be $true
9090 }
91+
92+ It " determine script with whitespace before closing comment is valid" {
93+ $scriptName = " ScriptWithWhitespaceBeforeClosingComment.ps1"
94+ $scriptFilePath = Join-Path $script :testScriptsFolderPath - ChildPath $scriptName
95+
96+ Test-PSScriptFileInfo $scriptFilePath | Should - Be $true
97+ }
9198}
Original file line number Diff line number Diff line change 1+
2+ <# PSScriptInfo
3+
4+ .VERSION 1.0
5+
6+ .GUID 3951be04-bd06-4337-8dc3-a620bf539fbd
7+
8+ .AUTHOR annavied
9+
10+ .COMPANYNAME
11+
12+ .COPYRIGHT
13+
14+ .TAGS
15+
16+ .LICENSEURI
17+
18+ .PROJECTURI
19+
20+ .ICONURI
21+
22+ .EXTERNALMODULEDEPENDENCIES
23+
24+ .REQUIREDSCRIPTS
25+
26+ .EXTERNALSCRIPTDEPENDENCIES
27+
28+ .RELEASENOTES
29+
30+
31+ .PRIVATEDATA
32+
33+ #>
34+
35+ <#
36+
37+ . DESCRIPTION
38+ this is a test for a script that will be published remotely
39+
40+ #>
41+ Param ()
42+
You can’t perform that action at this time.
0 commit comments