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

63 lines
6.2 KiB
JavaScript
Raw Normal View History

2016-05-13 23:18:44 +00:00
"use strict";
/// <reference path="./typings/main.d.ts" />
var plugins = require("./beautylog.plugins");
var beautylog_log_helpers_1 = require("./beautylog.log.helpers");
2016-05-19 17:27:09 +00:00
exports.oraActive = false; // when an Ora is active (e.g. start()) this is true;
2016-05-13 23:18:44 +00:00
var Ora = (function () {
function Ora(textArg, colorArg, startArg) {
if (startArg === void 0) { startArg = false; }
2016-05-13 23:18:44 +00:00
this._oraObject = plugins.ora({
spinner: "dots",
text: textArg,
color: colorArg
});
startArg ? this._oraObject.start() : void (0);
2016-05-13 23:18:44 +00:00
}
Ora.prototype.text = function (textArg) {
this._oraObject.text = textArg;
};
;
2016-05-14 15:51:35 +00:00
Ora.prototype.start = function (textArg, colorArg) {
if (textArg)
this._oraObject.text = textArg;
if (colorArg)
this._oraObject.color = colorArg;
exports.activeOra = this;
2016-05-19 17:27:09 +00:00
exports.oraActive = true;
this._oraObject.start();
};
;
2016-05-13 23:18:44 +00:00
Ora.prototype.end = function () {
this._oraObject.stop();
this._oraObject.clear();
exports.activeOra = undefined;
2016-05-19 17:27:09 +00:00
exports.oraActive = false;
2016-05-13 23:18:44 +00:00
};
Ora.prototype.endOk = function (textArg) {
this.end();
beautylog_log_helpers_1.logNode(textArg, "ok");
2016-05-13 23:18:44 +00:00
};
;
Ora.prototype.endError = function (textArg) {
this.end();
beautylog_log_helpers_1.logNode(textArg, "error");
2016-05-13 23:18:44 +00:00
};
;
2016-05-19 17:27:09 +00:00
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();
};
2016-05-13 23:18:44 +00:00
return Ora;
}());
exports.Ora = Ora;
2016-05-19 17:27:09 +00:00
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZX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