LLazyEmail / markdown-to-email

GNU General Public License v3.0
8 stars 13 forks source link

replace with lodash #1539

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

https://github.com/LLazyEmail/markdown-to-email/blob/12dc2cf27f402142b385592d9d62e5fd50e49963/src/domain/helper-methods/cli.js#L31


import chalk from 'chalk';
import { forEach } from 'lodash';

const printMessage = ({ message, type }) => {
  if (!message) return;

  switch (type) {
    case 'yellow':
      console.log(chalk.yellow(message));
      break;
    case 'red':
      console.log(chalk.red(message));
      break;
    case 'red2':
      console.log(chalk.red.bold(message));
      break;
    case 'green1':
      console.log(chalk.green(message));
      break;
    case 'green2':
      console.log(chalk.green.bold(message));
      break;

    default:
      console.log(`Sorry, we are out of ${type}.`);
  }
};

function checkErrors(errors) {
  if (Object.values(errors).includes(false)) {
    // TODO replace with lodash
    forEach(errors, (_, error) => {
      if (!errors[error]) {
        const message = `ERROR source.md doesn't have ${error}`;

        printMessage(message, 'red');
      }
    });

    const message = 'The full template has not been parsed!';
    printMessage(message, 'red2');

    return true;
  }
  return false;
}

export { checkErrors, printMessage };
github-actions[bot] commented 1 year ago

Closed in 77e48fe80c4958ef9eab331e3cc8303192f659da