Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Commit

Permalink
Printing "complete" output when no results are found
Browse files Browse the repository at this point in the history
  • Loading branch information
Keegan Street committed Aug 28, 2016
1 parent b1ff3b3 commit 840e159
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/element-finder.js
Expand Up @@ -151,6 +151,7 @@ module.exports = function(options, progressCallback) {
'numberOfFiles': numberOfFiles,
'numberOfFilesWithMatches': numberOfFilesWithMatches,
'duration': duration,
'selector': options.selector,
'message': '\nFound ' + pluralise(totalMatches, 'match', 'matches') + ' in ' + pluralise(numberOfFilesWithMatches, 'file', 'files') + ' (' + duration + ' seconds).'
});
}
Expand All @@ -175,6 +176,18 @@ module.exports = function(options, progressCallback) {
for (i = 0; i < numberOfFiles; i += 1) {
processFile(i, files[i]);
}
if (totalMatches === 0) {
duration = (Date.now() - startTime) / 1000;
progressCallback({
'status': 'complete',
'totalMatches': totalMatches,
'numberOfFiles': numberOfFiles,
'numberOfFilesWithMatches': numberOfFilesWithMatches,
'duration': duration,
'selector': options.selector,
'message': '\nNo results found (' + duration + ' seconds).'
});
}
};

if (options.files) {
Expand Down
5 changes: 5 additions & 0 deletions test/test.js
Expand Up @@ -68,4 +68,9 @@ var CLIeasy = require('cli-easy'),
.expect('should find 11 matches in 3 files', /Found 11 matches in 3 files./)
.undiscuss()

.discuss('testing input that returns zero results')
.arg('-s ".made-up-classname-that-is-not-used"')
.expect('should find zero results', /No results found/)
.undiscuss()

.export(module);

0 comments on commit 840e159

Please sign in to comment.