MCPcopy Index your code
hub / github.com/angular/angular-cli / Spinner

Class Spinner

packages/angular_devkit/build_angular/src/utils/spinner.ts:13–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11import { isTTY } from './tty';
12
13export class Spinner {
14 private readonly spinner: Ora;
15
16 /** When false, only fail messages will be displayed. */
17 enabled = true;
18 readonly #isTTY = isTTY();
19
20 constructor(text?: string) {
21 this.spinner = ora({
22 text: text === undefined ? undefined : text + '\n',
23 // The below 2 options are needed because otherwise CTRL+C will be delayed
24 // when the underlying process is sync.
25 hideCursor: false,
26 discardStdin: false,
27 isEnabled: this.#isTTY,
28 });
29 }
30
31 set text(text: string) {
32 this.spinner.text = text;
33 }
34
35 get isSpinning(): boolean {
36 return this.spinner.isSpinning || !this.#isTTY;
37 }
38
39 succeed(text?: string): void {
40 if (this.enabled) {
41 this.spinner.succeed(text);
42 }
43 }
44
45 fail(text?: string): void {
46 this.spinner.fail(text && colors.redBright(text));
47 }
48
49 stop(): void {
50 this.spinner.stop();
51 }
52
53 start(text?: string): void {
54 if (this.enabled) {
55 this.spinner.start(text);
56 }
57 }
58}

Callers

nothing calls this directly

Calls 1

isTTYFunction · 0.90

Tested by

no test coverage detected