From f00098e1b9c76c9aa03508ff54d2b8fb1ac27a8d Mon Sep 17 00:00:00 2001 From: Joshua Dorenkamp Date: Sun, 29 Apr 2018 06:11:25 -0400 Subject: [PATCH] Add `showCount` option (#39) --- index.js | 9 +++++++-- readme.md | 9 ++++++++- test.js | 19 ++++++++++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 715bc1f..e9f56a2 100644 --- a/index.js +++ b/index.js @@ -14,13 +14,15 @@ module.exports = options => { logger: fancyLog, title: 'gulp-debug:', minimal: true, - showFiles: true + showFiles: true, + showCount: true }, options); if (process.argv.indexOf('--verbose') !== -1) { options.verbose = true; options.minimal = false; options.showFiles = true; + options.showCount = true; } let count = 0; @@ -43,7 +45,10 @@ module.exports = options => { count++; cb(null, file); }, cb => { - options.logger(options.title + ' ' + chalk.green(count + ' ' + plur('item', count))); + if (options.showCount) { + options.logger(options.title + ' ' + chalk.green(count + ' ' + plur('item', count))); + } + cb(); }); }; diff --git a/readme.md b/readme.md index ca9f68b..0921840 100644 --- a/readme.md +++ b/readme.md @@ -55,7 +55,14 @@ The [`stat` property](http://nodejs.org/api/fs.html#fs_class_fs_stats) will be s Type: `boolean`
Default: `true` -Setting this to false will skip printing the file names and only show the file count. +Print filenames. + +##### showCount + +Type: `boolean`
+Default: `true` + +Print the file count. ##### logger(message) diff --git a/test.js b/test.js index 245fea0..bd4dc28 100644 --- a/test.js +++ b/test.js @@ -88,7 +88,7 @@ test('output plural item count', async t => { t.is(logInspect.lastMessage, 'unicorn: 2 items'); }); -test('not output file names when `showFiles` is false.', async t => { +test('do not output file names when `showFiles` is false', async t => { const stream = debug({ logger: logInspect.logger, title: 'unicorn:', @@ -114,3 +114,20 @@ test('using the default logger', async t => { t.pass(); }); + +test('do not output count when `showCount` is false', async t => { + const stream = debug({ + logger: logInspect.logger, + title: 'unicorn:', + showCount: false + }); + const finish = pEvent(stream, 'finish'); + + stream.write(file, () => { + stream.end(file); + }); + + await finish; + + t.not(logInspect.lastMessage, 'unicorn: 1 item'); +});