UNPKG

773 BJavaScriptView Raw
1'use strict';
2
3module.exports = function reporter(middlewareOptions, options) {
4 const { log, state, stats } = options;
5
6 if (state) {
7 const displayStats = (middlewareOptions.stats !== false);
8
9 if (displayStats) {
10 if (stats.hasErrors()) {
11 log.error(stats.toString(middlewareOptions.stats));
12 } else if (stats.hasWarnings()) {
13 log.warn(stats.toString(middlewareOptions.stats));
14 } else {
15 log.info(stats.toString(middlewareOptions.stats));
16 }
17 }
18
19 let message = 'Compiled successfully.';
20
21 if (stats.hasErrors()) {
22 message = 'Failed to compile.';
23 } else if (stats.hasWarnings()) {
24 message = 'Compiled with warnings.';
25 }
26 log.info(message);
27 } else {
28 log.info('Compiling...');
29 }
30};