awesome-logging
Advanced tools
Comparing version 0.0.1-pre-alpha6 to 0.0.1-pre-alpha7
@@ -11,2 +11,6 @@ import { TextValue } from '../../../models/text-object'; | ||
export interface AwesomeLoggerSpinnerControl extends AwesomeLoggerBase { | ||
stop(options: { | ||
succeeded?: boolean; | ||
removeLine?: boolean; | ||
}): void; | ||
} |
@@ -9,2 +9,6 @@ import { TextObject } from '../../models/text-object'; | ||
private _animationIndex; | ||
private _stopped; | ||
private _cleared; | ||
private _succeed?; | ||
private _stoppedText?; | ||
constructor(options?: Partial<AwesomeLoggerSpinnerConfig>); | ||
@@ -14,3 +18,7 @@ hasChanges(): boolean; | ||
getNextLine(): TextObject; | ||
complete(options: any): void; | ||
stop(options: { | ||
succeeded?: boolean; | ||
removeLine?: boolean; | ||
text?: string; | ||
}): void; | ||
} |
@@ -48,13 +48,30 @@ "use strict"; | ||
AwesomeSpinnerLogger.prototype.getNextLine = function () { | ||
var _a, _b, _c; | ||
if (this._stopped) { | ||
if (this._cleared) { | ||
return text_object_1.TextObject.empty; | ||
} | ||
if (this._succeed === true) { | ||
return new text_object_1.TextObject('√', 'GREEN').append((_a = this._stoppedText) !== null && _a !== void 0 ? _a : this._text.text, this._text.color); | ||
} | ||
else if (this._succeed === false) { | ||
return new text_object_1.TextObject('X', 'RED').append((_b = this._stoppedText) !== null && _b !== void 0 ? _b : this._text.text, this._text.color); | ||
} | ||
else { | ||
return new text_object_1.TextObject((_c = this._stoppedText) !== null && _c !== void 0 ? _c : this._text.text, this._text.color); | ||
} | ||
} | ||
return new text_object_1.TextObject(this._options.spinnerFrames[this._animationIndex], this._options.spinnerColor) | ||
.append(this._text.text, this._text.color); | ||
}; | ||
AwesomeSpinnerLogger.prototype.complete = function (options) { | ||
AwesomeSpinnerLogger.prototype.stop = function (options) { | ||
clearInterval(this._animationInterval); | ||
if (options.deleteLine) { | ||
// this.delete(); | ||
this._stopped = true; | ||
if (options.removeLine) { | ||
this._cleared = true; | ||
return; | ||
} | ||
else { | ||
this.changed(); | ||
} | ||
this._succeed = options.succeeded; | ||
this._stoppedText = options.text; | ||
this.changed(); | ||
}; | ||
@@ -61,0 +78,0 @@ return AwesomeSpinnerLogger; |
@@ -10,3 +10,6 @@ import { AwesomeLoggerColor } from '../types/logger-color'; | ||
private _child?; | ||
private _empty; | ||
static empty: TextObject; | ||
constructor(text: string, color?: AwesomeLoggerColor, bgColor?: AwesomeLoggerColor); | ||
private empty; | ||
static create(text: string | TextObject | TextValue): TextObject; | ||
@@ -13,0 +16,0 @@ static ensureTextValue(text: string | TextValue): TextValue; |
@@ -20,2 +20,6 @@ "use strict"; | ||
} | ||
TextObject.prototype.empty = function () { | ||
this._empty = true; | ||
return this; | ||
}; | ||
TextObject.create = function (text) { | ||
@@ -163,2 +167,3 @@ if (typeof text === 'string') { | ||
}; | ||
TextObject.empty = new TextObject('').empty(); | ||
return TextObject; | ||
@@ -165,0 +170,0 @@ }()); |
{ | ||
"name": "awesome-logging", | ||
"version": "0.0.1-pre-alpha6", | ||
"version": "0.0.1-pre-alpha7", | ||
"description": "Advanced logging messages, interactive prompts, loading animations and more in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
196908
2818