Skip to content

Commit

Permalink
Merge pull request #23 from olegskl/fix-reporter-do-not-write-empty-l…
Browse files Browse the repository at this point in the history
…ines-to-console

fix(reporter): don't write empty report to console
  • Loading branch information
olegskl committed Apr 23, 2016
2 parents 6c22e8b + ec355e2 commit a96afde
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/reporter-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default function reporterFactory(config = {}, options = {}) {
*/
const formattedText = formatter(results);

if (config.console) {
if (config.console && formattedText.trim()) {
asyncTasks.push(
gulpUtil.log(`\n${formattedText}\n`)
);
Expand Down
15 changes: 15 additions & 0 deletions test/reporter-factory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,21 @@ test('reporter should NOT write to console if console param is false', t => {
gulpUtil.log.restore();
});

test('reporter should NOT write to console if formatter returned only whitespace', t => {
t.plan(1);
stub(gulpUtil, 'log');
const reporter = reporterFactory({
formatter() { return ' \n'; },
console: true
});
reporter({});
t.false(
gulpUtil.log.called,
'reporter has NOT written anything to console'
);
gulpUtil.log.restore();
});

test('reporter should NOT write to console by default', t => {
t.plan(1);
stub(gulpUtil, 'log');
Expand Down

0 comments on commit a96afde

Please sign in to comment.