118ca2c74aaf6ac23cdf77d0d456748cd4954c5aee8591f59138cb3fc5d8fcb548feb4e2fc91fa192300d0b537dea71359b03c04459b0d144e3f3d669ced5d 847 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. 'use strict';
  2. const chalk = require('chalk');
  3. function formatTitle(severity, message) {
  4. return chalk[bgColor(severity)].black('', message, '');
  5. }
  6. function formatText(severity, message) {
  7. return chalk[textColor(severity)](message);
  8. }
  9. function bgColor(severity) {
  10. const color = textColor(severity);
  11. return 'bg'+ capitalizeFirstLetter(color)
  12. }
  13. function textColor(severity) {
  14. switch (severity.toLowerCase()) {
  15. case 'success': return 'green';
  16. case 'info': return 'blue';
  17. case 'note': return 'white';
  18. case 'warning': return 'yellow';
  19. case 'error': return 'red';
  20. default: return 'red';
  21. }
  22. }
  23. function capitalizeFirstLetter(string) {
  24. return string.charAt(0).toUpperCase() + string.slice(1);
  25. }
  26. module.exports = {
  27. bgColor: bgColor,
  28. textColor: textColor,
  29. formatTitle: formatTitle,
  30. formatText: formatText
  31. };