diff --git a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache index 79419594858..6fed374afbd 100644 --- a/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache +++ b/modules/openapi-generator/src/main/resources/powershell/Build.ps1.mustache @@ -22,17 +22,17 @@ function Get-FunctionsToExport { throw $ParserErr } else { foreach ($name in 'Begin', 'Process', 'End') { - foreach ($Statement in $Ast."${name}Block".Statements) { - if ( + foreach ($Statement in $Ast."${name}Block".Statements) { + if ( [String]::IsNullOrWhiteSpace($Statement.Name) -or $Statement.Extent.ToString() -notmatch ('function\W+{0}' -f $Statement.Name) ) { - continue - } + continue + } - $Statement.Name - } + $Statement.Name + } } } } diff --git a/samples/client/petstore/powershell/Build.ps1 b/samples/client/petstore/powershell/Build.ps1 index d892ed4513e..dc4e005472d 100644 --- a/samples/client/petstore/powershell/Build.ps1 +++ b/samples/client/petstore/powershell/Build.ps1 @@ -28,17 +28,17 @@ function Get-FunctionsToExport { throw $ParserErr } else { foreach ($name in 'Begin', 'Process', 'End') { - foreach ($Statement in $Ast."${name}Block".Statements) { - if ( + foreach ($Statement in $Ast."${name}Block".Statements) { + if ( [String]::IsNullOrWhiteSpace($Statement.Name) -or $Statement.Extent.ToString() -notmatch ('function\W+{0}' -f $Statement.Name) ) { - continue - } + continue + } - $Statement.Name - } + $Statement.Name + } } } }