Skip to content

Commit

Permalink
support continue when error occurs - fixes #34
Browse files Browse the repository at this point in the history
  • Loading branch information
SamVerschueren committed Jan 27, 2017
1 parent 085f3f2 commit ade4068
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 2 additions & 0 deletions index.js
Expand Up @@ -26,6 +26,8 @@ class Listr {
this._tasks = [];
this._RendererClass = renderer.getRenderer(this._options.renderer, this._options.nonTTYRenderer);

this.exitOnError = this._options.exitOnError;

this.add(tasks || []);
}

Expand Down
17 changes: 16 additions & 1 deletion lib/task.js
Expand Up @@ -84,6 +84,10 @@ class Task extends Subject {
const handleResult = result => {
// Detect the subtask
if (utils.isListr(result)) {
result._options = Object.assign(this._options, result._options);

result.exitOnError = result._options.exitOnError;

result.setRenderer(renderer.getRenderer('silent'));
this._subtasks = result.tasks;

Expand Down Expand Up @@ -148,7 +152,18 @@ class Task extends Subject {
})
.catch(err => {
this.state = state.FAILED;
throw err;

this._output = err.message;

this.next({
type: 'DATA',
data: err.message
});

if (this._listr.exitOnError !== false) {
// Do not exit when explicitely set to `false`
throw err;
}
})
.then(() => {
// Mark the Observable as completed
Expand Down

0 comments on commit ade4068

Please sign in to comment.