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(
127
127
{
128
128
string line = fileContents [ i ] ;
129
129
130
- if ( line . StartsWith ( "<#PSScriptInfo" ) )
130
+ if ( line . Trim ( ) . StartsWith ( "<#PSScriptInfo" ) )
131
131
{
132
132
int j = i + 1 ; // start at the next line
133
133
// keep grabbing lines until we get to closing #>
134
134
while ( j < fileContents . Length )
135
135
{
136
136
string blockLine = fileContents [ j ] ;
137
137
psScriptInfoCommentContent . Add ( blockLine ) ;
138
- if ( blockLine . StartsWith ( "#>" ) )
138
+ if ( blockLine . Trim ( ) . StartsWith ( "#>" ) )
139
139
{
140
140
141
141
reachedPSScriptInfoCommentEnd = true ;
@@ -157,7 +157,7 @@ internal static bool TryParseScriptFileContents(
157
157
return false ;
158
158
}
159
159
}
160
- else if ( line . StartsWith ( "<#" ) )
160
+ else if ( line . Trim ( ) . StartsWith ( "<#" ) )
161
161
{
162
162
// The next comment block must be the help comment block (containing description)
163
163
// keep grabbing lines until we get to closing #>
@@ -166,7 +166,7 @@ internal static bool TryParseScriptFileContents(
166
166
{
167
167
string blockLine = fileContents [ j ] ;
168
168
169
- if ( blockLine . StartsWith ( "#>" ) )
169
+ if ( blockLine . Trim ( ) . StartsWith ( "#>" ) )
170
170
{
171
171
reachedHelpInfoCommentEnd = true ;
172
172
i = j + 1 ;
Original file line number Diff line number Diff line change @@ -88,4 +88,11 @@ Describe "Test Test-PSScriptFileInfo" -tags 'CI' {
88
88
89
89
Test-PSScriptFileInfo $scriptFilePath | Should - Be $true
90
90
}
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
+ }
91
98
}
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