Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const reporter = (title, reports) => {
let success;
const titleColor = reports.summary.success ? chalk.green : chalk.red;
terminal.echo(`${chalk.cyan(title)} diagnosis ${titleColor(`${reports.summary.success ? '(^_^)' : 'ಠ_ಠ'} ${reports.summary.nb ? ` [${reports.summary.nb.success}/${reports.summary.nb.total}]` : ''}`)}\n`);
totals.success += reports.summary.nb.success;
totals.failure += reports.summary.nb.failure;
if (reports.summary.success && !verbose) {
terminal.echoIndent(chalk.green(`${figures.tick} ${reports.summary.nb.total === 1 ? reports.last.message : 'All tests passed'}`));
} else {
reports.list.forEach((test) => {
if (test.success && verbose) {
terminal.echoIndent(`${chalk.green(figures.tick)} ${chalk.dim(test.message)}`);
} else if (!test.success) {
let extra = '';
if (test.differences) {
extra += test.differences.superfluous && test.differences.superfluous.length !== 0 ? chalk.yellow(` [+] ${test.differences.superfluous.join(' | ')}`) : '';
extra += test.differences.missing && test.differences.missing.length !== 0 ? chalk.red(` [-] ${test.differences.missing.join(' | ')}`) : '';
extra += test.differences.mismatched && test.differences.mismatched.length !== 0 ? chalk.red(` [*] ${test.differences.mismatched.join(' | ')}`) : '';
}
if (test.outdated) {
reports.list.forEach((test) => {
if (test.success && verbose) {
terminal.echoIndent(`${chalk.green(figures.tick)} ${chalk.dim(test.message)}`);
} else if (!test.success) {
let extra = '';
if (test.differences) {
extra += test.differences.superfluous && test.differences.superfluous.length !== 0 ? chalk.yellow(` [+] ${test.differences.superfluous.join(' | ')}`) : '';
extra += test.differences.missing && test.differences.missing.length !== 0 ? chalk.red(` [-] ${test.differences.missing.join(' | ')}`) : '';
extra += test.differences.mismatched && test.differences.mismatched.length !== 0 ? chalk.red(` [*] ${test.differences.mismatched.join(' | ')}`) : '';
}
if (test.outdated) {
extra += ` ${chalk.dim(test.outdated.current)} → ${chalk.yellow(test.outdated.latest)}`;
}
if (test.linterOutput) {
extra += `\n${test.linterOutput}`;