@@ -60,7 +60,14 @@ function Join-PipeScript
6060 }
6161 }
6262
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+ }
6471 $AllScriptBlocks = @ (
6572 foreach ($toMerge in $AllScriptBlocks ) {
6673 if ($toMerge.Ast.body ) {
@@ -72,13 +79,13 @@ function Join-PipeScript
7279
7380
7481 $mergedScript = @ (
75- if ($SkipBlockType -notcontains ' using' ) {
82+ if ($BlockType -contains ' using' ) {
7683 foreach ($usingStatement in $AllScriptBlocks.Ast.UsingStatements ) {
7784 $usingStatement.Extent.ToString ()
7885 }
7986 }
8087
81- if ($SkipBlockType -notcontains ' requires' ) {
88+ if ($BlockType -contains ' requires' ) {
8289 foreach ($requirement in $AllScriptBlocks.Ast.ScriptRequirements ) {
8390 if ($requirement.RequirementPSVersion ) {
8491 " #requires -Version $ ( $requirement.RequirementPSVersion ) "
@@ -110,7 +117,7 @@ function Join-PipeScript
110117 }
111118 }
112119
113- if ($SkipBlockType -notcontains ' param' ) {
120+ if ($BlockType -contains ' param' ) {
114121 foreach ($combined in $AllScriptBlocks.Ast.ParamBlock ) {
115122 if (-not $combined.Parent.Extent ) { continue }
116123 $combined.Parent.Extent.ToString ().Substring(0 , $combined.Extent.StartOffset )
@@ -119,7 +126,7 @@ function Join-PipeScript
119126 # Start the param block
120127
121128 $alreadyIncludedParameter = [Ordered ]@ {}
122- if ($SkipBlockType -notcontains ' param' ) {
129+ if ($BlockType -contains ' param' ) {
123130 if (@ ($AllScriptBlocks.Ast.ParamBlock ) -ne $null ) {
124131 ' ' * (@ (@ ($AllScriptBlocks.Ast.ParamBlock ) -ne $null )[0 ] | MeasureIndent) + " param("
125132 }
@@ -168,7 +175,7 @@ function Join-PipeScript
168175 }
169176 }
170177
171- if ($SkipBlockType -notcontains ' dynamicParam' ) {
178+ if ($BlockType -contains ' dynamicParam' ) {
172179 $blocks = @ ($AllScriptBlocks.Ast.DynamicParamBlock )
173180 if ($blocks -ne $null ) {
174181 $blockOpen = $false
@@ -187,7 +194,7 @@ function Join-PipeScript
187194
188195
189196
190- if ($SkipBlockType -notcontains ' begin' ) { # If there were begin blocks,
197+ if ($BlockType -contains ' begin' ) { # If there were begin blocks,
191198 $blocks = @ ($AllScriptBlocks.Ast.BeginBlock )
192199 if ($blocks -ne $null ) {
193200 $blockOpen = $false
@@ -204,7 +211,7 @@ function Join-PipeScript
204211 }
205212 }
206213
207- if ($SkipBlockType -notcontains ' process' ) { # If there were process blocks
214+ if ($BlockType -contains ' process' ) { # If there were process blocks
208215 $blocks = @ ($AllScriptBlocks.Ast.ProcessBlock )
209216 if ($blocks -ne $null ) {
210217 $blockOpen = $false
@@ -221,7 +228,7 @@ function Join-PipeScript
221228 }
222229 }
223230
224- if ($SkipBlockType -notcontains ' end' ) {
231+ if ($BlockType -contains ' end' ) {
225232 # If there were end blcoks declared
226233
227234 $blocks = @ ($AllScriptBlocks.Ast.EndBlock )
0 commit comments