Skip to content

Commit

Permalink
feat(find): add verbose ouput option (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
ta2edchimp authored and sarbbottam committed Apr 21, 2016
1 parent 66e6159 commit 1bc45f4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/bin/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var options = {
getAllAvailableRules: ['all-available', 'a'],
getUnusedRules: ['unused', 'u'],
n: ['no-error'],
verbose: ['verbose', 'v'],
}

var argv = require('yargs')
Expand All @@ -27,12 +28,12 @@ Object.keys(options).forEach(function findRules(option) {
var ruleFinderMethod = ruleFinder[option]
if (argv[option] && ruleFinderMethod) {
rules = ruleFinderMethod()
/* istanbul ignore next */
argv.verbose && cli.push('\n' + options[option][0] + ' rules\n' + rules.length + ' rules found\n')
if (rules.length) {
cli.push('\n' + options[option][0] + ' rules\n')
!argv.verbose && cli.push('\n' + options[option][0] + ' rules\n')
cli.push(rules)
cli.write()
} else if (option === 'getUnusedRules') {
} else /* istanbul ignore else */ if (option === 'getUnusedRules') {
processExitCode = 0
}
}
Expand Down
9 changes: 8 additions & 1 deletion test/bin/find.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ var stub = {
describe('bin', function() {
beforeEach(function() {
console.log = function() { // eslint-disable-line no-console
if (arguments[0].match(/(current|plugin|all\-available|unused)/)) {
if (arguments[0].match(/(current|plugin|all\-available|unused|rules found)/)) {
return
}
consoleLog.apply(null, arguments)
Expand Down Expand Up @@ -86,4 +86,11 @@ describe('bin', function() {
proxyquire('../../src/bin/find', stub)
assert.ok(getUnusedRules.called)
})

it('logs verbosely', function() {
process.argv[2] = '-c'
process.argv[3] = '-v'
proxyquire('../../src/bin/find', stub)
assert.ok(getCurrentRules.called)
})
})

0 comments on commit 1bc45f4

Please sign in to comment.