From c55f9d42da4d9dec44b8438d9bb83200df0fc61e Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Wed, 8 Feb 2023 18:27:33 +0530 Subject: [PATCH] feat: better error handling in bru cli --- packages/bruno-cli/src/commands/run.js | 32 ++++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/bruno-cli/src/commands/run.js b/packages/bruno-cli/src/commands/run.js index fb49ae55a..80900bbd3 100644 --- a/packages/bruno-cli/src/commands/run.js +++ b/packages/bruno-cli/src/commands/run.js @@ -162,13 +162,17 @@ const handler = async function (argv) { console.log(chalk.yellow('Running Request \n')); const bruContent = fs.readFileSync(filename, 'utf8'); const bruJson = bruToJson(bruContent); - const { - assertionResults, - testResults - } = await runSingleRequest(filename, bruJson, collectionPath, collectionVariables, envVars); + const result = await runSingleRequest(filename, bruJson, collectionPath, collectionVariables, envVars); - printRunSummary(assertionResults, testResults); - console.log(chalk.dim(chalk.grey('Done.'))); + if(result) { + const { + assertionResults, + testResults + } = result; + + printRunSummary(assertionResults, testResults); + console.log(chalk.dim(chalk.grey('Done.'))); + } } const _isDirectory = await isDirectory(filename); @@ -209,13 +213,17 @@ const handler = async function (argv) { bruFilepath, bruJson } = iter; - const { - assertionResults: _assertionResults, - testResults: _testResults - } = await runSingleRequest(bruFilepath, bruJson, collectionPath, collectionVariables, envVars); + const result = await runSingleRequest(bruFilepath, bruJson, collectionPath, collectionVariables, envVars); - assertionResults = assertionResults.concat(_assertionResults); - testResults = testResults.concat(_testResults); + if(result) { + const { + assertionResults: _assertionResults, + testResults: _testResults + } = result; + + assertionResults = assertionResults.concat(_assertionResults); + testResults = testResults.concat(_testResults); + } } printRunSummary(assertionResults, testResults);