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

63 lines
6.2 KiB
JavaScript

"use strict";
require("typings-global");
var plugins = require("./beautylog.plugins");
var beautylog_log_helpers_1 = require("./beautylog.log.helpers");
exports.oraActive = false; // when an Ora is active (e.g. start()) this is true;
var Ora = (function () {
function Ora(textArg, colorArg, startArg) {
if (startArg === void 0) { startArg = false; }
this._oraObject = plugins.ora({
spinner: "dots",
text: textArg,
color: colorArg
});
startArg ? this._oraObject.start() : void (0);
}
Ora.prototype.text = function (textArg) {
this._oraObject.text = textArg;
};
;
Ora.prototype.start = function (textArg, colorArg) {
if (textArg)
this._oraObject.text = textArg;
if (colorArg)
this._oraObject.color = colorArg;
exports.activeOra = this;
exports.oraActive = true;
this._oraObject.start();
};
;
Ora.prototype.end = function () {
this._oraObject.stop();
this._oraObject.clear();
exports.activeOra = undefined;
exports.oraActive = false;
};
Ora.prototype.endOk = function (textArg) {
this.end();
beautylog_log_helpers_1.logNode(textArg, "ok");
};
;
Ora.prototype.endError = function (textArg) {
this.end();
beautylog_log_helpers_1.logNode(textArg, "error");
};
;
Ora.prototype.pause = function () {
this._oraObject.stop();
};
Ora.prototype.stop = function () {
this.end();
};
// log methods that play nice with ora
Ora.prototype.log = function (logText, logType) {
this.stop();
beautylog_log_helpers_1.logNode(logText, logType);
this.start();
};
return Ora;
}());
exports.Ora = Ora;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5jbGFzc2VzLm9yYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLElBQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0Msc0NBQXNCLHlCQUF5QixDQUFDLENBQUE7QUFFckMsaUJBQVMsR0FBVyxLQUFLLENBQUMsQ0FBQyxxREFBcUQ7QUFHM0Y7SUFHSSxhQUFZLE9B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