Skip to content

Commit

Permalink
add custom-reporters. #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
srph committed Feb 24, 2016
1 parent 75a1039 commit a0c2b02
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
27 changes: 21 additions & 6 deletions bin/npm-scripts-info
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
#!/usr/bin/env node
var chalk = require('chalk');
var info = require('../lib');
var meow = require('meow');

var scripts = info();

for ( var script in scripts ) {
var description = scripts[script];
var cli = meow([
'Usage',
' npm-scripts-info [hr]',
'',
'Options',
' --help, -h Display usage',
' --reporter, -r Specify the custom reporter to be used',
'',
'Examples',
' npm-scripts-info -r=my-reporter'
].join('\n'), {
string: ['reporter'],
alias: {
reporter: 'r',
help: 'h'
}
});

console.log(chalk.blue(script) + ':');
console.log(' ' + chalk.green(description));
}
cli.flags.reporter
? require('npm-scripts-info-' + cli.flags.reporter)(scripts)
: require('../lib/reporter')(scripts);
12 changes: 12 additions & 0 deletions lib/reporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
var chalk = require('chalk');

function reporter(scripts) {
for ( var script in scripts ) {
var description = scripts[script];

console.log(chalk.blue(script) + ':');
console.log(' ' + chalk.green(description));
}
}

module.exports = reporter;
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"rewire": "^2.5.1"
},
"dependencies": {
"chalk": "^1.1.1"
"chalk": "^1.1.1",
"meow": "^3.7.0"
}
}

0 comments on commit a0c2b02

Please sign in to comment.