You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
813 B

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