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-10-16 00:26:43 +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({
|
2016-10-16 00:26:43 +00:00
|
|
|
spinner: 'dots',
|
2016-05-13 23:18:44 +00:00
|
|
|
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
|
|
|
}
|
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
|
|
|
}
|
|
|
|
start(textArg, colorArg) {
|
2016-10-16 00:26:43 +00:00
|
|
|
if (textArg) {
|
2016-05-14 15:51:35 +00:00
|
|
|
this._oraObject.text = textArg;
|
2016-10-16 00:26:43 +00:00
|
|
|
}
|
|
|
|
if (colorArg) {
|
2016-05-14 15:51:35 +00:00
|
|
|
this._oraObject.color = colorArg;
|
2016-10-16 00:26:43 +00:00
|
|
|
}
|
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-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
end() {
|
2016-05-13 23:18:44 +00:00
|
|
|
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-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
endOk(textArg) {
|
2016-05-13 23:18:44 +00:00
|
|
|
this.end();
|
2016-10-16 00:26:43 +00:00
|
|
|
beautylog_log_helpers_1.logNode('ok', textArg);
|
2016-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
endError(textArg) {
|
2016-05-13 23:18:44 +00:00
|
|
|
this.end();
|
2016-10-16 00:26:43 +00:00
|
|
|
beautylog_log_helpers_1.logNode('error', textArg);
|
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() {
|
2016-05-14 14:26:38 +00:00
|
|
|
this.end();
|
2016-07-23 17:47:23 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-13 23:18:44 +00:00
|
|
|
exports.Ora = Ora;
|
2016-10-16 00:26:43 +00:00
|
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYmVhdXR5bG9nLmNsYXNzZXMub3JhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvYmVhdXR5bG9nLmNsYXNzZXMub3JhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSwwQkFBdUI7QUFDdkIsK0NBQThDO0FBQzlDLG1FQUErQztBQUVwQyxRQUFBLFNBQVMsR0FBWSxLQUFLLENBQUEsQ0FBQyxvREFBb0Q7QUFHMUY7SUFHSSxZQUFZLE9BQWUsRUFBQyxRQUFnQixFQUFDLFFBQVEsR0FBWSxLQUFLO1FBQ2xFLElBQUksQ0FBQyxVQUFVLEdBQUcsT0FBTyxDQUFDLEdBQUcsQ0FBQztZQUMxQixPQUFPLEVBQUUsTUFBTTtZQUNmLElBQUksRUFBRSxPQUFPO1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