Skip to content

Commit

Permalink
Add showCount option (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaDoshua authored and sindresorhus committed Apr 29, 2018
1 parent 22a7e80 commit f00098e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 4 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
});
};
9 changes: 8 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ The [`stat` property](http://nodejs.org/api/fs.html#fs_class_fs_stats) will be s
Type: `boolean`<br>
Default: `true`

Setting this to false will skip printing the file names and only show the file count.
Print filenames.

##### showCount

Type: `boolean`<br>
Default: `true`

Print the file count.

##### logger(message)

Expand Down
19 changes: 18 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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:',
Expand All @@ -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');
});

0 comments on commit f00098e

Please sign in to comment.