tender-cli
Version:
Command line interface for Tender
50 lines (38 loc) • 1.67 kB
JavaScript
// Generated by CoffeeScript 1.6.2
var JSONReporter, Reporter, fs, _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
fs = require('fs');
Reporter = require('../../reporter');
JSONReporter = (function(_super) {
__extends(JSONReporter, _super);
function JSONReporter() {
this.print = __bind(this.print, this);
this.format = __bind(this.format, this); _ref = JSONReporter.__super__.constructor.apply(this, arguments);
return _ref;
}
JSONReporter.prototype.format = function(callback) {
this.output = JSON.stringify(this.data, null, 2);
return callback();
};
JSONReporter.prototype.print = function(callback) {
var file, _ref1, _ref2,
_this = this;
if (!this.data) {
return callback();
}
file = ((_ref1 = this.options) != null ? (_ref2 = _ref1.cmdOptions) != null ? _ref2.output : void 0 : void 0) || "tender_output.json";
return fs.writeFile(file, this.output, function() {
if (!_this.options.silent) {
console.log("" + _this.data.length + " records exported to " + file);
}
return callback();
});
};
return JSONReporter;
})(Reporter);
module.exports = function(options, callback) {
return new JSONReporter(options, callback);
};
module.exports.description = "Exports JSON file with all fields";