@@ -60,7 +60,14 @@ function Join-PipeScript
60
60
}
61
61
}
62
62
63
- end {
63
+ end {
64
+ if ($SkipBlockType ) {
65
+ foreach ($skipBlock in $SkipBlockType ) {
66
+ if ($blockType -contains $skipBlock ) {
67
+ $blockType = $BlockType -ne $skipBlock
68
+ }
69
+ }
70
+ }
64
71
$AllScriptBlocks = @ (
65
72
foreach ($toMerge in $AllScriptBlocks ) {
66
73
if ($toMerge.Ast.body ) {
@@ -72,13 +79,13 @@ function Join-PipeScript
72
79
73
80
74
81
$mergedScript = @ (
75
- if ($SkipBlockType -notcontains ' using' ) {
82
+ if ($BlockType -contains ' using' ) {
76
83
foreach ($usingStatement in $AllScriptBlocks.Ast.UsingStatements ) {
77
84
$usingStatement.Extent.ToString ()
78
85
}
79
86
}
80
87
81
- if ($SkipBlockType -notcontains ' requires' ) {
88
+ if ($BlockType -contains ' requires' ) {
82
89
foreach ($requirement in $AllScriptBlocks.Ast.ScriptRequirements ) {
83
90
if ($requirement.RequirementPSVersion ) {
84
91
" #requires -Version $ ( $requirement.RequirementPSVersion ) "
@@ -110,7 +117,7 @@ function Join-PipeScript
110
117
}
111
118
}
112
119
113
- if ($SkipBlockType -notcontains ' param' ) {
120
+ if ($BlockType -contains ' param' ) {
114
121
foreach ($combined in $AllScriptBlocks.Ast.ParamBlock ) {
115
122
if (-not $combined.Parent.Extent ) { continue }
116
123
$combined.Parent.Extent.ToString ().Substring(0 , $combined.Extent.StartOffset )
@@ -119,7 +126,7 @@ function Join-PipeScript
119
126
# Start the param block
120
127
121
128
$alreadyIncludedParameter = [Ordered ]@ {}
122
- if ($SkipBlockType -notcontains ' param' ) {
129
+ if ($BlockType -contains ' param' ) {
123
130
if (@ ($AllScriptBlocks.Ast.ParamBlock ) -ne $null ) {
124
131
' ' * (@ (@ ($AllScriptBlocks.Ast.ParamBlock ) -ne $null )[0 ] | MeasureIndent) + " param("
125
132
}
@@ -168,7 +175,7 @@ function Join-PipeScript
168
175
}
169
176
}
170
177
171
- if ($SkipBlockType -notcontains ' dynamicParam' ) {
178
+ if ($BlockType -contains ' dynamicParam' ) {
172
179
$blocks = @ ($AllScriptBlocks.Ast.DynamicParamBlock )
173
180
if ($blocks -ne $null ) {
174
181
$blockOpen = $false
@@ -187,7 +194,7 @@ function Join-PipeScript
187
194
188
195
189
196
190
- if ($SkipBlockType -notcontains ' begin' ) { # If there were begin blocks,
197
+ if ($BlockType -contains ' begin' ) { # If there were begin blocks,
191
198
$blocks = @ ($AllScriptBlocks.Ast.BeginBlock )
192
199
if ($blocks -ne $null ) {
193
200
$blockOpen = $false
@@ -204,7 +211,7 @@ function Join-PipeScript
204
211
}
205
212
}
206
213
207
- if ($SkipBlockType -notcontains ' process' ) { # If there were process blocks
214
+ if ($BlockType -contains ' process' ) { # If there were process blocks
208
215
$blocks = @ ($AllScriptBlocks.Ast.ProcessBlock )
209
216
if ($blocks -ne $null ) {
210
217
$blockOpen = $false
@@ -221,7 +228,7 @@ function Join-PipeScript
221
228
}
222
229
}
223
230
224
- if ($SkipBlockType -notcontains ' end' ) {
231
+ if ($BlockType -contains ' end' ) {
225
232
# If there were end blcoks declared
226
233
227
234
$blocks = @ ($AllScriptBlocks.Ast.EndBlock )
0 commit comments