(stats)
| 23 | |
| 24 | // eslint-disable-next-line max-statements |
| 25 | function formatOutput(stats) { |
| 26 | const output = []; |
| 27 | const hasErrors = stats.hasErrors(); |
| 28 | const hasWarnings = stats.hasWarnings(); |
| 29 | |
| 30 | const json = stats.toJson({ |
| 31 | source: true // Needed for webpack5+ |
| 32 | }); |
| 33 | let formattedErrors = json.errors.map(message => `Error in ${_formatMessage(message)}`); |
| 34 | const formattedWarnings = json.warnings.map(message => `Warning in ${_formatMessage(message)}`); |
| 35 | |
| 36 | if (hasErrors) { |
| 37 | output.push("{red-fg}Failed to compile.{/}"); |
| 38 | output.push(""); |
| 39 | if (formattedErrors.some(_isLikelyASyntaxError)) { |
| 40 | formattedErrors = formattedErrors.filter(_isLikelyASyntaxError); |
| 41 | } |
| 42 | formattedErrors.forEach(message => { |
| 43 | output.push(message); |
| 44 | output.push(""); |
| 45 | }); |
| 46 | return _lineJoin(output); |
| 47 | } |
| 48 | |
| 49 | if (hasWarnings) { |
| 50 | output.push("{yellow-fg}Compiled with warnings.{/yellow-fg}"); |
| 51 | output.push(""); |
| 52 | formattedWarnings.forEach(message => { |
| 53 | output.push(message); |
| 54 | output.push(""); |
| 55 | }); |
| 56 | |
| 57 | return _lineJoin(output); |
| 58 | } |
| 59 | |
| 60 | output.push("{green-fg}Compiled successfully!{/}"); |
| 61 | output.push(""); |
| 62 | |
| 63 | return _lineJoin(output); |
| 64 | } |
| 65 | |
| 66 | module.exports = { formatOutput, _formatMessage, _isLikelyASyntaxError, _lineJoin }; |
no test coverage detected
searching dependent graphs…