mirror of
https://github.com/jackyzha0/quartz.git
synced 2025-05-18 14:34:23 +02:00
use readline instead
This commit is contained in:
parent
07ffc8681e
commit
de727b4686
@ -1,3 +1,5 @@
|
|||||||
|
import readline from "readline"
|
||||||
|
|
||||||
export class QuartzLogger {
|
export class QuartzLogger {
|
||||||
verbose: boolean
|
verbose: boolean
|
||||||
private spinnerInterval: NodeJS.Timeout | undefined
|
private spinnerInterval: NodeJS.Timeout | undefined
|
||||||
@ -16,8 +18,8 @@ export class QuartzLogger {
|
|||||||
} else {
|
} else {
|
||||||
this.spinnerIndex = 0
|
this.spinnerIndex = 0
|
||||||
this.spinnerInterval = setInterval(() => {
|
this.spinnerInterval = setInterval(() => {
|
||||||
process.stdout.clearLine(0)
|
readline.clearLine(process.stdout, 0)
|
||||||
process.stdout.cursorTo(0)
|
readline.cursorTo(process.stdout, 0)
|
||||||
process.stdout.write(`${this.spinnerChars[this.spinnerIndex]} ${this.spinnerText}`)
|
process.stdout.write(`${this.spinnerChars[this.spinnerIndex]} ${this.spinnerText}`)
|
||||||
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerChars.length
|
this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerChars.length
|
||||||
}, 100)
|
}, 100)
|
||||||
@ -32,8 +34,8 @@ export class QuartzLogger {
|
|||||||
if (!this.verbose && this.spinnerInterval) {
|
if (!this.verbose && this.spinnerInterval) {
|
||||||
clearInterval(this.spinnerInterval)
|
clearInterval(this.spinnerInterval)
|
||||||
this.spinnerInterval = undefined
|
this.spinnerInterval = undefined
|
||||||
process.stdout.clearLine(0)
|
readline.clearLine(process.stdout, 0)
|
||||||
process.stdout.cursorTo(0)
|
readline.cursorTo(process.stdout, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user