2016-05-13 23:18:44 +00:00
|
|
|
"use strict";
|
2016-05-23 07:10:30 +00:00
|
|
|
require("typings-global");
|
2016-05-13 23:18:44 +00:00
|
|
|
var plugins = require("./beautylog.plugins");
|
2016-05-16 22:24:56 +00:00
|
|
|
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 () {
|
2016-05-14 14:26:38 +00:00
|
|
|
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
|
|
|
|
});
|
2016-05-14 14:26:38 +00:00
|
|
|
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;
|
2016-05-16 22:24:56 +00:00
|
|
|
exports.activeOra = this;
|
2016-05-19 17:27:09 +00:00
|
|
|
exports.oraActive = true;
|
2016-05-14 14:26:38 +00:00
|
|
|
this._oraObject.start();
|
|
|
|
};
|
|
|
|
;
|
2016-05-13 23:18:44 +00:00
|
|
|
Ora.prototype.end = function () {
|
|
|
|
this._oraObject.stop();
|
|
|
|
this._oraObject.clear();
|
2016-05-16 22:24:56 +00:00
|
|
|
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();
|
2016-05-16 22:24:56 +00:00
|
|
|
beautylog_log_helpers_1.logNode(textArg, "ok");
|
2016-05-13 23:18:44 +00:00
|
|
|
};
|
|
|
|
;
|
|
|
|
Ora.prototype.endError = function (textArg) {
|
|
|
|
this.end();
|
2016-05-16 22:24:56 +00:00
|
|
|
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();
|
|
|
|
};
|
2016-05-14 14:26:38 +00:00
|
|
|
Ora.prototype.stop = function () {
|
|
|
|
this.end();
|
|
|
|
};
|
|
|
|
// log methods that play nice with ora
|
|
|
|
Ora.prototype.log = function (logText, logType) {
|
|
|
|
this.stop();
|
2016-05-16 22:24:56 +00:00
|
|
|
beautylog_log_helpers_1.logNode(logText, logType);
|
2016-05-14 14:26:38 +00:00
|
|
|
this.start();
|
|
|
|
};
|
2016-05-13 23:18:44 +00:00
|
|
|
return Ora;
|
|
|
|
}());
|
|
|
|
exports.Ora = Ora;
|
|
|
|
|
2016-06-11 23:13:16 +00:00
|
|
|
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImJlYXV0eWxvZy5jbGFzc2VzLm9yYS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFBZ0IsQ0FBQyxDQUFBO0FBQ3hCLElBQVksT0FBTyxXQUFNLHFCQUFxQixDQUFDLENBQUE7QUFDL0Msc0NBQXNCLHlCQUF5QixDQUFDLENBQUE7QUFFckMsaUJBQVMsR0FBVyxLQUFLLENBQUMsQ0FBQyxxREFBcUQ7QUFHM0Y7SUFHSSxhQUFZLE9BQWMsRUFBQyxRQUFlLEVBQUMsUUFBd0I7UUFBeEIsd0JBQXdCLEdBQXhCLGdCQUF3QjtRQUM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