Skip to content

Commit

Permalink
Run Newman: return process exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
thim81 committed Oct 28, 2023
1 parent 9b4686b commit 2c973d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/application/newman/runNewmanWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,18 @@ export const runNewmanWith = async (
// Merge Newman default and runtime options
const newmanOptions = { ...defaultNewmanOptions, ...newmanRunOptionsCased }

return new Promise((resolve, reject) => {
return new Promise(resolve => {
try {
newman.run(newmanOptions).on('done', (err: Error, summary) => {
if (err || summary.error) {
reject(err || summary.error)
console.error(chalk.red('Collection run encountered an error.'))
if (err) {
console.error(chalk.red(err.message))
}
if (summary.error) {
console.error(chalk.red(summary.error.message))
}
process.exit(1)
} else {
console.log(chalk.green('Collection run completed.'))
resolve()
Expand Down

0 comments on commit 2c973d9

Please sign in to comment.