base-reporter v0.2.0
base-reporter

Base application smart plugin for caching data and adding and running custom report functions.
Install
Install with npm:
$ npm install base-reporter --saveUsage
var reporter = require('base-reporter');API
reporter
Exposes smart plugin for adding a reporter instance to a base application.
Params
config{Object}: Configuration object.returns{Function}: Plugin function to use withapp.use
Example
app.use(reporter());.reporter.middleware
Creates a middleware function that can be used with application middleware methods.
Params
fn{String|Function}: Pass a property string or function that will create a middleware function. Defaults tofiles.returns{Function}: Function that can be used as a middleware function.
Example
// Default middleware will cache all files on the `reporter.files` array (can be accessed in report functions):
app.preWrite(/./, app.reporter.middleware());
// Pass a custom property string to cache files on another property:
app.preWrite(/./, app.reporter.middleware('templates'));
// Pass a custom function that creates the middleware function. The function will take the reporter instance:
app.preWrite(/./, app.reporter.middleware(function(reporter) {
var counter = 0;
return function(file, next) {
reporter.union('files', file);
reporter.set('counter', ++counter);
next():
};
}));.reporter.add
Add a report function to the reporter with the given name. Function may take the reporter instance and options as parameters.
Params
name{String}: Name of the reporterfn{Function}: report function to run when .reporter.report(name) is called.returns{Object}this: to enable chaining
Example
app.reporter.add('basic', function(reporter, options) {
console.log(this.files);
});.reporter.report
Run a registered report function with the given options.
Params
name{String}: Name of the report to run.returns{Object}this: to enable chaining
Example
app.reporter.report('basic', {foo: 'bar'});
//=> file1.js,file2.js,file3.jsContributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with verb:
$ npm install verb && npm run docsOr, if verb is installed globally:
$ verbRunning tests
Install dev dependencies:
$ npm install -d && npm testAuthor
Brian Woodward
License
Copyright © 2016, Brian Woodward. Released under the MIT license.
This file was generated by verb, v0.9.0, on June 16, 2016.