( response: CommandFailureDiagnosticInput, fallbackMessage = 'Unknown error', )
| 63 | } |
| 64 | |
| 65 | export function diagnosticsFromCommandFailure( |
| 66 | response: CommandFailureDiagnosticInput, |
| 67 | fallbackMessage = 'Unknown error', |
| 68 | ): BasicDiagnostics { |
| 69 | const stderrLines = response.error ? nonEmptyLines(response.error) : []; |
| 70 | const stdoutLines = response.output ? nonEmptyLines(response.output) : []; |
| 71 | |
| 72 | if (stderrLines.length > 0) { |
| 73 | const diagnostics = createBasicDiagnostics({ errors: stderrLines }); |
| 74 | if (stdoutLines.length > 0 && stdoutLines.join('\n') !== stderrLines.join('\n')) { |
| 75 | diagnostics.rawOutput = stdoutLines; |
| 76 | } |
| 77 | return diagnostics; |
| 78 | } |
| 79 | |
| 80 | if (stdoutLines.length > 0) { |
| 81 | return createBasicDiagnostics({ errors: stdoutLines }); |
| 82 | } |
| 83 | |
| 84 | return diagnosticsFromErrorMessage(fallbackMessage); |
| 85 | } |
no test coverage detected