-
Notifications
You must be signed in to change notification settings - Fork 138
Mlonis fix for issue 165 #555
base: development
Are you sure you want to change the base?
Conversation
Removed trailing whitespace on line 90. Refactored lines 96-97 to be a one line code. This enhancement functions like the original code, but now won't add an extra newline if the release notes provided are null or empty.
Removed trailing whitespace from the help info text.
1. Removed trailing whitespace on line 444 (now line 454) 2. Refactored lines 399 to no longer add extra whitespace in the event that $requiredStrings is the empty string 3. Added new code between lines 405 and 406 to fully resolve issue #165
|
||
.REQUIREDSCRIPTS$(if ($RequiredScripts) {" $($RequiredScripts -join ',')"}) | ||
|
||
.EXTERNALSCRIPTDEPENDENCIES$(if ($ExternalScriptDependencies) {" $($ExternalScriptDependencies -join ',')"}) | ||
|
||
.RELEASENOTES | ||
$($ReleaseNotes -join "`r`n") | ||
.RELEASENOTES$(if ($ReleaseNotes) {`r`n$($ReleaseNotes -join "`r`n")}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This simplifies the code into one line and further prevents the addition of a new line when the release notes section is being left blank or empty.
if ($requiresStrings.Trim() -ne "") { | ||
$tempContents += "$PSScriptInfoString`r`n`r`n$($requiresStrings -join "`r`n")" | ||
} else { | ||
$tempContents += $PSScriptInfoString | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This resolves issue #165 by not adding extra newlines if the user did not supply any required modules. If the user does not supply any required modules, Get-RequiresString returns the empty string.
} elseif (($scriptFileContents[$i + 1] -eq "`r`n" -or $scriptFileContents[$i + 1] -eq "") -and (($i + 1) -lt $scriptFileContents.Count)) { | ||
# This condition will only be met if the line is a Requires -Module statement. | ||
# To adding newlines everytime the function is called on a script, we must increment i by 1 | ||
# if the next line after the caught Requires -Module statement is the empty string or a `r`n | ||
# This prevents extra newlines from being inserted | ||
$i = $i + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section accounts for the edge case where a script file already has Requires -Module statements and prevents the addition of new lines by incrementing $i when it detects that the line following the last Requires -Modules statement is a character return newline sequence or the empty string.
Description
This pull request resolves issue #165 .
Changelog
Get-PSScriptInfoString.ps1
Get-ScriptCommentHelpInfoString.ps1
Update-ScriptFileInfo.ps1