From 1b4d9b8f6edfc8f712c165c347f9e3819c133532 Mon Sep 17 00:00:00 2001 From: Johannes Zorn <46689904+jzorn@users.noreply.github.com> Date: Wed, 5 Jun 2024 17:05:28 +0200 Subject: [PATCH] fix: Move output to stderr #2123 (#2125) This change moves informational command outputs from console.log (prints on stdout) to console.warn/console.error (prints on stderr) to enable stdout processing in pipelines. Co-authored-by: Anoop M D --- packages/bruno-cli/src/commands/run.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/bruno-cli/src/commands/run.js b/packages/bruno-cli/src/commands/run.js index 00f592bd2..7cf5293fb 100644 --- a/packages/bruno-cli/src/commands/run.js +++ b/packages/bruno-cli/src/commands/run.js @@ -406,8 +406,7 @@ const handler = async function (argv) { return aSequence - bSequence; }); } else { - console.log(chalk.yellow('Running Folder Recursively \n')); - + console.warn(chalk.yellow('Running Folder Recursively \n')); bruJsons = getBruFilesRecursively(filename, testsOnly); } } @@ -461,7 +460,7 @@ const handler = async function (argv) { if (nextRequestIdx >= 0) { currentRequestIndex = nextRequestIdx; } else { - console.error("Could not find request with name '" + nextRequestName + "'"); + console.warn("Could not find request with name '" + nextRequestName + "'"); currentRequestIndex++; } } else { @@ -471,7 +470,7 @@ const handler = async function (argv) { const summary = printRunSummary(results); const totalTime = results.reduce((acc, res) => acc + res.response.responseTime, 0); - console.log(chalk.dim(chalk.grey(`Ran all requests - ${totalTime} ms`))); + console.error(chalk.dim(chalk.grey(`Ran all requests - ${totalTime} ms`))); if (outputPath && outputPath.length) { const outputDir = path.dirname(outputPath); @@ -494,15 +493,14 @@ const handler = async function (argv) { makeHtmlOutput(outputJson, outputPath); } - console.log(chalk.dim(chalk.grey(`Wrote results to ${outputPath}`))); + console.error(chalk.dim(chalk.grey(`Wrote results to ${outputPath}`))); } if (summary.failedAssertions + summary.failedTests + summary.failedRequests > 0) { process.exit(constants.EXIT_STATUS.ERROR_FAILED_COLLECTION); } } catch (err) { - console.log('Something went wrong'); - console.error(chalk.red(err.message)); + console.error(chalk.red('Something went wrong: ' + err.message)); process.exit(constants.EXIT_STATUS.ERROR_GENERIC); } };