60 lines
6.0 KiB
JavaScript
60 lines
6.0 KiB
JavaScript
"use strict";
|
|
/// <reference path="./typings/main.d.ts" />
|
|
var plugins = require("./beautylog.plugins");
|
|
var beautylog_log_helpers_1 = require("./beautylog.log.helpers");
|
|
exports.isOraActive = 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.isOraActive = true;
|
|
this._oraObject.start();
|
|
};
|
|
;
|
|
Ora.prototype.end = function () {
|
|
this._oraObject.stop();
|
|
this._oraObject.clear();
|
|
exports.activeOra = undefined;
|
|
exports.isOraActive = 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.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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5jbGFzc2VzLm9yYS50cyJdLCJuYW1lcyI6W10sIm1hc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