feat: better error handling in bru cli

This commit is contained in:
Anoop M D 2023-02-08 18:27:33 +05:30
parent 2f32f7024e
commit c55f9d42da

View File

@ -162,13 +162,17 @@ const handler = async function (argv) {
console.log(chalk.yellow('Running Request \n')); console.log(chalk.yellow('Running Request \n'));
const bruContent = fs.readFileSync(filename, 'utf8'); const bruContent = fs.readFileSync(filename, 'utf8');
const bruJson = bruToJson(bruContent); const bruJson = bruToJson(bruContent);
const { const result = await runSingleRequest(filename, bruJson, collectionPath, collectionVariables, envVars);
assertionResults,
testResults
} = await runSingleRequest(filename, bruJson, collectionPath, collectionVariables, envVars);
printRunSummary(assertionResults, testResults); if(result) {
console.log(chalk.dim(chalk.grey('Done.'))); const {
assertionResults,
testResults
} = result;
printRunSummary(assertionResults, testResults);
console.log(chalk.dim(chalk.grey('Done.')));
}
} }
const _isDirectory = await isDirectory(filename); const _isDirectory = await isDirectory(filename);
@ -209,13 +213,17 @@ const handler = async function (argv) {
bruFilepath, bruFilepath,
bruJson bruJson
} = iter; } = iter;
const { const result = await runSingleRequest(bruFilepath, bruJson, collectionPath, collectionVariables, envVars);
assertionResults: _assertionResults,
testResults: _testResults
} = await runSingleRequest(bruFilepath, bruJson, collectionPath, collectionVariables, envVars);
assertionResults = assertionResults.concat(_assertionResults); if(result) {
testResults = testResults.concat(_testResults); const {
assertionResults: _assertionResults,
testResults: _testResults
} = result;
assertionResults = assertionResults.concat(_assertionResults);
testResults = testResults.concat(_testResults);
}
} }
printRunSummary(assertionResults, testResults); printRunSummary(assertionResults, testResults);