From c080ab81ef3c1065b0ce430fe7f18a0e6ae7bdc3 Mon Sep 17 00:00:00 2001 From: Nicholas Lim <18374483+niclim@users.noreply.github.com> Date: Mon, 25 Sep 2023 08:30:29 -0400 Subject: [PATCH] log run output incrementally (#2334) --- projects/optic/src/commands/run.ts | 56 ++++++++++++++---------------- 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/projects/optic/src/commands/run.ts b/projects/optic/src/commands/run.ts index 14e5b4a57f..ebcb88b862 100644 --- a/projects/optic/src/commands/run.ts +++ b/projects/optic/src/commands/run.ts @@ -225,34 +225,32 @@ type SpecReport = { }; }; -function report(specReports: SpecReport[]) { - for (const report of specReports) { - logger.info(`| ${chalk.bold(report.title)} (${report.path})`); - if (report.error) { - logger.warn(`| Optic encountered an error: ${report.error}`); - return; - } - const breakingChangesReport = !report.diffs - ? '☑️ No changes ' - : report.breakingChanges - ? `❌ ${report.breakingChanges} breaking change${ - report.breakingChanges > 1 ? 's' : '' - } ` - : '✅ No breaking changes '; - - const designReport = report.designIssues - ? `❌ ${report.designIssues} design issue${ - report.designIssues > 1 ? 's' : '' - } ` - : '✅ Design '; - - logger.info(`| ${breakingChangesReport}${designReport}`); - - if (report.changelogLink) { - logger.info(`| View report: ${report.changelogLink}`); - } - logger.info(''); +function report(report: SpecReport) { + logger.info(`| ${chalk.bold(report.title)} (${report.path})`); + if (report.error) { + logger.warn(`| Optic encountered an error: ${report.error}`); + return; } + const breakingChangesReport = !report.diffs + ? '☑️ No changes ' + : report.breakingChanges + ? `❌ ${report.breakingChanges} breaking change${ + report.breakingChanges > 1 ? 's' : '' + } ` + : '✅ No breaking changes '; + + const designReport = report.designIssues + ? `❌ ${report.designIssues} design issue${ + report.designIssues > 1 ? 's' : '' + } ` + : '✅ Design '; + + logger.info(`| ${breakingChangesReport}${designReport}`); + + if (report.changelogLink) { + logger.info(`| View report: ${report.changelogLink}`); + } + logger.info(''); } // Dirty dirty, lemon squeezy @@ -536,9 +534,9 @@ export const getRunAction = changelogUrl: changelogUrl ?? '', results: specResults.results, }); - } - report(specReports); + report(specReport); + } if (commentToken && isPR) { const data = results.map((result) => ({