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

59 lines
3.6 KiB
JavaScript
Raw Normal View History

2016-05-13 23:18:44 +00:00
"use strict";
2016-05-23 07:10:30 +00:00
require("typings-global");
2016-07-23 17:47:23 +00:00
const plugins = require("./beautylog.plugins");
const 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-07-23 17:47:23 +00:00
class Ora {
constructor(textArg, colorArg, 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
}
2016-07-23 17:47:23 +00:00
text(textArg) {
2016-05-13 23:18:44 +00:00
this._oraObject.text = textArg;
2016-07-23 17:47:23 +00:00
}
2016-05-13 23:18:44 +00:00
;
2016-07-23 17:47:23 +00:00
start(textArg, colorArg) {
2016-05-14 15:51:35 +00:00
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-07-23 17:47:23 +00:00
}
;
2016-07-23 17:47:23 +00:00
end() {
2016-05-13 23:18:44 +00:00
this._oraObject.stop();
this._oraObject.clear();
exports.activeOra = undefined;
2016-05-19 17:27:09 +00:00
exports.oraActive = false;
2016-07-23 17:47:23 +00:00
}
endOk(textArg) {
2016-05-13 23:18:44 +00:00
this.end();
beautylog_log_helpers_1.logNode(textArg, "ok");
2016-07-23 17:47:23 +00:00
}
2016-05-13 23:18:44 +00:00
;
2016-07-23 17:47:23 +00:00
endError(textArg) {
2016-05-13 23:18:44 +00:00
this.end();
beautylog_log_helpers_1.logNode(textArg, "error");
2016-07-23 17:47:23 +00:00
}
2016-05-13 23:18:44 +00:00
;
2016-07-23 17:47:23 +00:00
pause() {
2016-05-19 17:27:09 +00:00
this._oraObject.stop();
2016-07-23 17:47:23 +00:00
}
stop() {
this.end();
2016-07-23 17:47:23 +00:00
}
// log methods that play nice with ora
2016-07-23 17:47:23 +00:00
log(logText, logType) {
this.stop();
beautylog_log_helpers_1.logNode(logText, logType);
this.start();
2016-07-23 17:47:23 +00:00
}
}
2016-05-13 23:18:44 +00:00
exports.Ora = Ora;
2016-07-23 17:47:23 +00:00
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNsYXNzZXMub3JhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLmNsYXNzZXMub3JhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUFnQixDQUFDLENBQUE7QUFDeEIsTUFBWSxPQUFPLFdBQU0scUJBQXFCLENBQUMsQ0FBQTtBQUMvQyx3Q0FBc0IseUJBQXlCLENBQUMsQ0FBQTtBQUVyQyxpQkFBUyxHQUFXLEtBQUssQ0FBQyxDQUFDLHFEQUFxRDtBQUczRjtJQUdJLFlBQVksT0FBYyxFQUFDLFFBQWUsRUFBQyxRQUFRLEdBQVcsS0FBSztRQUMvRCxJQUFJLENBQUMsVUFBVSxHQUFHLE9BQU8sQ0FBQyxHQUFHLENBQUM7WUFDMUIsT0FBTyxFQUFDLE1BQU07WUFDZCxJQUFJLEVBQUMsT0FBTztZQUNaLEtBQUssRUFBQyxRQUFRO1NBQ2pCLENBQUMsQ0FBQztRQUVILFFBQVEsR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLEtBQUssRUFBRSxHQUFHLEtBQUksQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUNqRCxDQUFDO0lBQ0QsSUFBSSxDQUFDLE9BQU87UUFDUixJQUFJLENBQUMsVUFBVSxDQUFDLElBQUksR0FBRyxPQUFPLENBQUM7SUFDbkMsQ0FBQzs7SUFFRCxLQUFLLENBQUMsT0FBZSxFQUFDLFFBQWd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