smartlog-destination-local/dist/beautylog.classes.ora.js
2017-01-21 19:29:20 +01:00

53 lines
3.1 KiB
JavaScript

"use strict";
require("typings-global");
const plugins = require("./beautylog.plugins");
const beautylog_log_helpers_1 = require("./beautylog.log.helpers");
exports.oraActive = false; // when an Ora is active (e.g. start()) this is true
class Ora {
constructor(textArg, colorArg, startArg = false) {
this._oraObject = plugins.ora({
spinner: 'dots',
text: textArg,
color: colorArg
});
if (startArg) {
this.start();
}
}
text(textArg) {
this._oraObject.text = textArg;
}
start(textArg, colorArg) {
if (textArg) {
this.text(textArg);
}
if (colorArg) {
this._oraObject.color = colorArg;
}
exports.activeOra = this;
exports.oraActive = true;
this._oraObject.start();
}
end() {
this._oraObject.stop();
this._oraObject.clear();
exports.activeOra = undefined;
exports.oraActive = false;
}
endOk(textArg) {
this.end();
beautylog_log_helpers_1.logNode('ok', textArg);
}
endError(textArg) {
this.end();
beautylog_log_helpers_1.logNode('error', textArg);
}
pause() {
this._oraObject.stop();
}
stop() {
this.end();
}
}
exports.Ora = Ora;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNsYXNzZXMub3JhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLmNsYXNzZXMub3JhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIsK0NBQThDO0FBQzlDLG1FQUErQztBQUVwQyxRQUFBLFNBQVMsR0FBWSxLQUFLLENBQUEsQ0FBQyxvREFBb0Q7QUFHMUY7SUFHSSxZQUFZLE9BQWUsRUFBQyxRQUFnQixFQUFDLFdBQW9CLEtBQUs7UUFDbEUsSUFBSSxDQUFDLFVBQVUsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDO1lBQzFCLE9BQU8sRUFBRSxNQUFNO1lBQ2YsSUFBSSxFQUFFLE9BQU87WUFDYixLQUFLLEVBQU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