Skip to content

Commit

Permalink
fix(concurrent): Wait for all tasks to finish before showing errors
Browse files Browse the repository at this point in the history
When running tasks in parallel (by deafult), we want to run all linters
and display all errors after they finished their work.

Fixes #86
  • Loading branch information
okonet committed Feb 19, 2017
1 parent 3c75c16 commit 5a44bea
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,34 @@ cosmiconfig('lint-staged', {
task.fileList,
packageJson,
{ gitDir, verbose }
)
), {
// In sub-tasks we don't want to run concurrently
// and we want to abort on errors
concurrent: false,
exitOnError: true
}
)
)
}))


if (tasks.length) {
new Listr(tasks, { concurrent, renderer }).run().catch((error) => {
console.error(error.message)
process.exit(1)
new Listr(tasks, {
concurrent,
renderer,
exitOnError: !concurrent // Wait for all errors when running concurrently
})
.run()
.catch((error) => {
if (Array.isArray(error.errors)) {
error.errors.forEach((lintError) => {
console.error(lintError.message)
})
} else {
console.log(error.message)
}
process.exit(1)
})
}
})
})
Expand Down

0 comments on commit 5a44bea

Please sign in to comment.