success-handler.js 529 B

1234567891011121314151617181920212223
  1. 'use strict';
  2. /**
  3. * Dependencies
  4. */
  5. const chalk = require('chalk');
  6. /**
  7. * Success handler
  8. */
  9. module.exports = function successHandler(results, verbose) {
  10. const changed = results.filter(result => result.hasChanged);
  11. const numChanges = changed.length;
  12. if (numChanges > 0) {
  13. console.log(chalk.green(`${numChanges} file(s) were changed`));
  14. if (verbose) {
  15. changed.forEach(result => console.log(chalk.grey('-', result.file)));
  16. }
  17. }
  18. else {
  19. console.log(chalk.yellow('No files were changed'));
  20. }
  21. };