Skip to content

Commit

Permalink
fix: Bugfix parallel execution aborted when some runner throws error
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesin11 committed Oct 25, 2020
1 parent 26d28b5 commit eb52da9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const main = async () => {
const result = await runner.run()

if (result.isFailure()) {
console.info('Some runners return error!')
console.error(result.value)
process.exitCode = 1
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ export class CompositRunner implements Runner {
}

async run(): Promise<Result<void, Error>> {
const results = await Promise.all(
const results = await Promise.allSettled(
this.runners.map((runner) => runner.run())
)

const errorResults = results.filter(result => result.isFailure())
const errorResults = results.filter((result) => {
return result.status === 'rejected' ||
(result.status === 'fulfilled' && result.value.isFailure())
})
if (errorResults.length > 0) {
console.log('End with failure')
return failure(new Error('Some runner throws error'))
return failure(new Error('Some runner throws error!!'))
}

return success()
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"incremental": true, /* Enable incremental compilation */
"target": "ES2019", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
"lib": ["es2020"], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
Expand Down

0 comments on commit eb52da9

Please sign in to comment.