tender-cli
Version:
Command line interface for Tender
59 lines (47 loc) • 1.4 kB
JavaScript
// Generated by CoffeeScript 1.6.2
var Reporter, async,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
async = require('async');
Reporter = (function() {
function Reporter(options, callback) {
var _ref;
this.options = options;
this.callback = callback;
this.print = __bind(this.print, this);
this.format = __bind(this.format, this);
this.map = __bind(this.map, this);
this.run = __bind(this.run, this);
if (!((_ref = this.options) != null ? _ref.data : void 0)) {
return this.callback(new Error('No data input to reporter'));
}
this.run();
}
Reporter.prototype.run = function() {
var _this = this;
return async.series([this.map, this.format, this.print], function(err) {
if (_this.callback) {
return _this.callback(err, _this.output);
}
});
};
Reporter.prototype.map = function(callback) {
this.data = this.options.data;
return callback();
};
Reporter.prototype.format = function(callback) {
if (!this.data) {
return callback();
}
this.output = this.data.toString();
return callback();
};
Reporter.prototype.print = function(callback) {
if (this.options.silent || !this.data) {
return callback();
}
console.log(this.output);
return callback();
};
return Reporter;
})();
module.exports = Reporter;