diff --git a/cli/spinner.ts b/cli/spinner.ts index 3498ce4cfa97..7f5e49224f27 100644 --- a/cli/spinner.ts +++ b/cli/spinner.ts @@ -136,13 +136,16 @@ export class Spinner { // Updates the spinner after the given interval. const updateFrame = () => { const color = this.#color ?? ""; - Deno.stdout.writeSync(LINE_CLEAR); const frame = encoder.encode( noColor ? this.#spinner[i] + " " + this.message : color + this.#spinner[i] + COLOR_RESET + " " + this.message, ); - Deno.stdout.writeSync(frame); + // call writeSync once to reduce flickering + const writeData = new Uint8Array(LINE_CLEAR.length + frame.length); + writeData.set(LINE_CLEAR); + writeData.set(frame, LINE_CLEAR.length); + Deno.stdout.writeSync(writeData); i = (i + 1) % this.#spinner.length; }; this.#intervalId = setInterval(updateFrame, this.#interval);