|
87 | 87 | if ($TypeName.IsGeneric) { |
88 | 88 | $TypeNameParams[$typeName.Name] = |
89 | 89 | $typeName.GenericArguments | |
90 | | - UnpackTypeConstraintArgs |
| 90 | + TypeConstraintToArguments |
91 | 91 | } elseif (-not $TypeName.IsArray) { |
92 | 92 | $TypeNameArgs += $TypeName.Name |
93 | 93 | } |
|
127 | 127 |
|
128 | 128 |
|
129 | 129 | # If the command is a ```[ScriptBlock]``` |
130 | | - if ($Command -is [scriptblock]) |
| 130 | + if ($Command -is [scriptblock]) |
131 | 131 | { |
132 | 132 | # Attempt to transpile it. |
133 | 133 | $TranspiledScriptBlock = $Command | .>Pipescript @ErrorsAndWarnings |
|
142 | 142 | }) |
143 | 143 | return |
144 | 144 | } |
| 145 | + |
| 146 | + if ($TranspilerErrors) { |
| 147 | + $failedMessage = @( |
| 148 | + "$($command.Source): " + "$($TranspilerErrors.Count) error(s)" |
| 149 | + if ($transpilerWarnings) { |
| 150 | + "$($TranspilerWarnings.Count) warning(s)" |
| 151 | + } |
| 152 | + ) -join ',' |
| 153 | + Write-Error $failedMessage -ErrorId Build.Failed -TargetObject ( |
| 154 | + [PSCustomObject][ordered]@{ |
| 155 | + Output = $pipescriptOutput |
| 156 | + Errors = $TranspilerErrors |
| 157 | + Warnings = $TranspilerWarnings |
| 158 | + Command = $Command |
| 159 | + Parameters = $InvokePipeScriptParameters |
| 160 | + } |
| 161 | + ) |
| 162 | + } |
| 163 | + |
145 | 164 | # If it could not be transpiled into a [ScriptBlock] or [ScriptBlock[]] |
146 | | - if ($transpiledScriptBlock -isnot [ScriptBlock] -and -not ($TranspiledScriptBlock -as [scriptblock[]])) { |
| 165 | + if ($TranspilerErrors -or |
| 166 | + ($transpiledScriptBlock -isnot [ScriptBlock] -and -not ($TranspiledScriptBlock -as [scriptblock[]]))) { |
147 | 167 | # error out. |
148 | 168 | Write-Error "Command {$command} could not be transpiled into [ScriptBlock]s" |
149 | 169 | return |
|
0 commit comments