smartlog-destination-local/dist/beautylog.classes.js

55 lines
6.3 KiB
JavaScript

"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./beautylog.plugins");
var tableHelpers = {
makeRow: function (cellCounterArg, colorArg) {
if (cellCounterArg === void 0) { cellCounterArg = 2; }
if (colorArg === void 0) { colorArg = "cyan"; }
var rowArray = [];
for (var i = 0; i < (cellCounterArg); i++) {
rowArray.push(String(i + 1).cyan);
}
return rowArray;
}
};
var ConsoleTable = (function () {
function ConsoleTable(tableTypeArg, tableHeadArrayArg) {
if (tableHeadArrayArg === void 0) { tableHeadArrayArg = tableHelpers.makeRow(); }
switch (tableTypeArg) {
case "checks":
this.tableHead = ['Check Item:'.cyan, 'Status:'.cyan];
break;
case "custom":
this.tableHead = tableHeadArrayArg;
break;
default:
break;
}
this.rows = [];
this.type = tableTypeArg;
}
ConsoleTable.prototype.push = function (row) {
this.rows.push(row);
};
ConsoleTable.prototype.print = function () {
var table = new plugins.cliTable({
head: this.tableHead
});
for (var row in this.rows) {
if (this.rows[row][1] == "success") {
this.rows[row][1] = ' '.bgGreen + ' ' + this.rows[row][1];
}
else if (this.rows[row][1] == "error") {
this.rows[row][1] = ' '.bgRed + ' ' + this.rows[row][1];
}
table.push(this.rows[row]);
}
;
console.log(table.toString());
};
return ConsoleTable;
}());
exports.ConsoleTable = ConsoleTable;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5jbGFzc2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSw0Q0FBNEM7QUFDNUMsSUFBTyxPQUFPLFdBQVcscUJBQXFCLENBQUMsQ0FBQztBQUVoRCxJQUFJLFlBQVksR0FBRztJQUNmLE9BQU8sRUFBRSxVQUFTLGNBQXlCLEVBQUMsUUFBd0I7UUFBbEQsOEJBQXlCLEdBQXpCLGtCQUF5QjtRQUFDLHdCQUF3QixHQUF4QixpQkFBd0I7UUFDaEUs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iY3VzdG9tXCI6XG4gICAgICAgICAgICAgICAgdGhpcy50YWJsZUhlYWQgPSB0YWJsZUhlYWRBcnJheUFyZztcbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5yb3dzID0gW107XG4gICAgICAgIHRoaXMudHlwZSA9IHRhYmxlVHlwZUFyZztcbiAgICB9XG4gICAgcHVzaChyb3c6c3RyaW5nW10pe1xuICAgICAgICB0aGlzLnJvd3MucHVzaChyb3cpO1xuICAgIH1cbiAgICBwcmludCgpIHtcbiAgICAgICAgdmFyIHRhYmxlID0gbmV3IHBsdWdpbnMuY2xpVGFibGUoe1xuICAgICAgICAgICAgaGVhZDogdGhpcy50YWJsZUhlYWRcbiAgICAgICAgfSk7XG4gICAgICAgIGZvciAodmFyIHJvdyBpbiB0aGlzLnJvd3Mpe1xuICAgICAgICAgICAgaWYodGhpcy5yb3dzW3Jvd11bMV0gPT0gXCJzdWNjZXNzXCIpe1xuICAgICAgICAgICAgICAgIHRoaXMucm93c1tyb3ddWzFdID0gJyAnLmJnR3JlZW4gKyAnICcgKyB0aGlzLnJvd3Nbcm93XVsxXTtcbiAgICAgICAgICAgIH0gZWxzZSBpZiAodGhpcy5yb3dzW3Jvd11bMV0gPT0gXCJlcnJvclwiKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5yb3dzW3Jvd11bMV0gPSAnICcuYmdSZWQgKyAnICcgKyB0aGlzLnJvd3Nbcm93XVsxXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHRhYmxlLnB1c2godGhpcy5yb3dzW3Jvd10pO1xuICAgICAgICB9O1xuICAgICAgICBjb25zb2xlLmxvZyh0YWJsZS50b1N0cmluZygpKTtcbiAgICB9XG59XG4iXSwic291cmNlUm9vdCI6Ii9zb3VyY2UvIn0=