Skip to content

Commit 22ebae7

Browse files
author
James Brundage
committed
New-PipeScript: Trimming whitespace
1 parent bec2f47 commit 22ebae7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

New-PipeScript.ps1.ps1

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function New-PipeScript
1+
function New-PipeScript
22
{
33
<#
44
.Synopsis
@@ -20,7 +20,7 @@ function New-PipeScript
2020
[ValidateScriptBlock(ParameterOnly)]
2121
[ValidateTypes(TypeName={[Collections.IDictionary], [string],[Object[]], [Scriptblock]})]
2222
$Parameter,
23-
23+
2424
# The dynamic parameter block.
2525
[Parameter(ValueFromPipelineByPropertyName)]
2626
[ValidateScriptBlock(NoBlocks, NoParameters)]
@@ -48,7 +48,7 @@ function New-PipeScript
4848
[Alias('EndBlock')]
4949
[ScriptBlock]
5050
$End,
51-
51+
5252
# The script header.
5353
[Parameter(ValueFromPipelineByPropertyName)]
5454
[string]
@@ -62,7 +62,7 @@ function New-PipeScript
6262
$allBeginBlocks = @()
6363
$allEndBlocks = @()
6464
$allProcessBlocks = @()
65-
$allHeaders = @()
65+
$allHeaders = @()
6666
}
6767

6868
process {
@@ -73,7 +73,7 @@ function New-PipeScript
7373
# If it is, walk thur each parameter in the dictionary
7474
foreach ($EachParameter in $Parameter.GetEnumerator()) {
7575
# Continue past any parameters we already have
76-
if ($ParametersToCreate.Contains($EachParameter.Key)) {
76+
if ($ParametersToCreate.Contains($EachParameter.Key)) {
7777
continue
7878
}
7979
# If the parameter is a string and the value is not a variable
@@ -98,12 +98,12 @@ function New-PipeScript
9898
# If there was a param block on the script block
9999
if ($EachParameter.Value.Ast.ParamBlock) {
100100
# embed the parameter block (except for the param keyword)
101-
$EachParameter.Value.Ast.ParamBlock.Extent.ToString() -replace
101+
$EachParameter.Value.Ast.ParamBlock.Extent.ToString() -replace
102102
'^[\s\r\n]{0,}param\(' -replace '\)[\s\r\n]{0,}$'
103103
} else {
104104
# Otherwise
105105
'[Parameter(ValueFromPipelineByPropertyName)]' + (
106-
$EachParameter.Value.ToString() -replace
106+
$EachParameter.Value.ToString() -replace
107107
"\`$$($eachParameter.Key)[\s\r\n]$" -replace # Replace any trailing variables
108108
'param\(\)[\s\r\n]{0,}$' # then replace any empty param blocks.
109109
)
@@ -117,15 +117,15 @@ function New-PipeScript
117117
} elseif ($Parameter -is [string]) {
118118
$ParametersToCreate[$Parameter] = @(
119119
"[Parameter(ValueFromPipelineByPropertyName)]"
120-
"`$$Parameter"
120+
"`$$Parameter"
121121
)
122122
} elseif ($parameter -is [scriptblock]) {
123123
$parameterScriptBlocks +=
124124
if ($parameter.Ast.ParamBlock) {
125125
# embed the parameter block (except for the param keyword)
126126
$parameter
127127
} else {
128-
128+
129129
}
130130
} elseif ($Parameter -is [Object[]]) {
131131
$currentParam = @()
@@ -176,12 +176,12 @@ function New-PipeScript
176176
if ($end) {
177177
$allEndBlocks += $end
178178
}
179-
179+
180180
}
181181

182182
end {
183-
$newParamBlock =
184-
"param(" + [Environment]::newLine +
183+
$newParamBlock =
184+
"param(" + [Environment]::newLine +
185185
$(@(foreach ($toCreate in $ParametersToCreate.GetEnumerator()) {
186186
$toCreate.Value -join [Environment]::NewLine
187187
}) -join (',' + [Environment]::NewLine)) +

0 commit comments

Comments
 (0)