| 476 | } |
| 477 | |
| 478 | #log(message: string, color?: AnsiColors, options?: LogOptions): void { |
| 479 | const print: (text: string) => void = options?.noLineBreak |
| 480 | ? text => process.stdout.write(text) |
| 481 | : console.log; |
| 482 | |
| 483 | if (this.#activeSpinner) { |
| 484 | if (this.#activeSpinner.isSpinning) { |
| 485 | this.#activeSpinnerLogs.push(this.#format(message, color)); |
| 486 | } else { |
| 487 | const indented = |
| 488 | options?.noIndent || !message ? message : indentLines(message, 2); |
| 489 | print(this.#format(indented, color)); |
| 490 | } |
| 491 | } else { |
| 492 | print(this.#format(message, color)); |
| 493 | } |
| 494 | this.#endsWithBlankLine = |
| 495 | (!message || message.endsWith('\n')) && !options?.noIndent; |
| 496 | } |
| 497 | |
| 498 | #format(message: string, color: AnsiColors | undefined): string { |
| 499 | if (!this.#groupColor || this.#activeSpinner?.isSpinning) { |