MCPcopy
hub / github.com/FormidableLabs/webpack-dashboard / formatOutput

Function formatOutput

utils/format-output.js:25–64  ·  view source on GitHub ↗
(stats)

Source from the content-addressed store, hash-verified

23
24// eslint-disable-next-line max-statements
25function 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
66module.exports = { formatOutput, _formatMessage, _isLikelyASyntaxError, _lineJoin };

Callers 1

setStatsMethod · 0.85

Calls 2

_formatMessageFunction · 0.85
_lineJoinFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…