Skip to content

Commit

Permalink
fix: Move output to stderr usebruno#2123
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jzorn committed Apr 18, 2024
1 parent d027d90 commit adc4932
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/bruno-cli/src/commands/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,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);
}
}
Expand Down Expand Up @@ -460,7 +459,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 {
Expand All @@ -470,7 +469,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);
Expand All @@ -493,15 +492,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(1);
}
} catch (err) {
console.log('Something went wrong');
console.error(chalk.red(err.message));
console.error(chalk.red('Something went wrong: ' + err.message));
process.exit(1);
}
};
Expand Down

0 comments on commit adc4932

Please sign in to comment.