Skip to content

Commit

Permalink
fix: always stop before special stop methods
Browse files Browse the repository at this point in the history
  • Loading branch information
snickbit committed Mar 30, 2023
1 parent 83ec63d commit af15a17
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions packages/spinner/src/Spinner.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,9 @@ export class Spinner extends EventEmitter {
* @param text
*/
finish(text?: string) {
if (this._started) {
this.#stop(text)
this.#renderLine(kLogSymbols.success)
this.emit('finished')
}
this.#stop(text)
this.#renderLine(kLogSymbols.success)
this.emit('finished')

return this
}
Expand All @@ -203,11 +201,9 @@ export class Spinner extends EventEmitter {
* @param text
*/
fail(text?: string) {
if (this._started) {
this.#stop(text)
this.#renderLine(kLogSymbols.error)
this.emit('failed')
}
this.#stop(text)
this.#renderLine(kLogSymbols.error)
this.emit('failed')

return this
}
Expand All @@ -217,11 +213,9 @@ export class Spinner extends EventEmitter {
* @param text
*/
stop(text?: string) {
if (this._started) {
this.#stop(text)
this.#renderLine(kLogSymbols.stop)
this.emit('stopped')
}
this.#stop(text)
this.#renderLine(kLogSymbols.stop)
this.emit('stopped')

return this
}
Expand Down Expand Up @@ -249,11 +243,9 @@ export class Spinner extends EventEmitter {
* @param text
*/
warn(text?: string) {
if (this._started) {
this.#stop(text)
this.#renderLine(kLogSymbols.warning)
this.emit('warned')
}
this.#stop(text)
this.#renderLine(kLogSymbols.warning)
this.emit('warned')

return this
}
Expand Down

0 comments on commit af15a17

Please sign in to comment.