Skip to content

Commit

Permalink
feat(renderer): log task output if skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine committed Oct 11, 2018
1 parent 58806da commit 463d706
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ui/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ class Renderer {
}

if (task.isSkipped()) {
if (task.output && typeof task.output === 'string') {
this.ui.log(task.output, 'yellow');
}

this.spinner.info(`${task.title} ${chalk.gray('[skipped]')}`);
}

Expand Down
31 changes: 31 additions & 0 deletions test/unit/ui/renderer-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,37 @@ describe('Unit: UI > Renderer', function () {
expect(spinner.fail.called).to.be.false;
});

it('info spinner called when task skips, logs task output', function () {
const subStub = sinon.stub();
const log = sinon.stub();
const renderer = new Renderer({log}, [{
subscribe: subStub,
isCompleted: () => false,
isSkipped: () => true,
hasFailed: () => false,
output: 'test output',
isEnabled
}]);

const spinner = {
succeed: sinon.stub(),
info: sinon.stub(),
fail: sinon.stub()
};
renderer.spinner = spinner;
renderer.subscribeToEvents();

expect(subStub.calledOnce).to.be.true;
// update values and execute callback
subStub.firstCall.args[0]({type: 'STATE'});

expect(spinner.succeed.called).to.be.false;
expect(spinner.info.called).to.be.true;
expect(spinner.fail.called).to.be.false;
expect(log.calledOnce).to.be.true;
expect(log.calledWithExactly('test output'));
});

it('fail spinner called when task failed', function () {
const subStub = sinon.stub();
const renderer = new Renderer({}, [{
Expand Down

0 comments on commit 463d706

Please sign in to comment.