UNPKG

1.35 kBJavaScriptView Raw
1"use strict";
2/**
3 * @license
4 * Copyright Google LLC All Rights Reserved.
5 *
6 * Use of this source code is governed by an MIT-style license that can be
7 * found in the LICENSE file at https://angular.io/license
8 */
9Object.defineProperty(exports, "__esModule", { value: true });
10exports.Spinner = void 0;
11const ora = require("ora");
12const color_1 = require("./color");
13class Spinner {
14 constructor(text) {
15 /** When false, only fail messages will be displayed. */
16 this.enabled = true;
17 this.spinner = ora({
18 text,
19 // The below 2 options are needed because otherwise CTRL+C will be delayed
20 // when the underlying process is sync.
21 hideCursor: false,
22 discardStdin: false,
23 });
24 }
25 set text(text) {
26 this.spinner.text = text;
27 }
28 succeed(text) {
29 if (this.enabled) {
30 this.spinner.succeed(text);
31 }
32 }
33 info(text) {
34 this.spinner.info(text);
35 }
36 fail(text) {
37 this.spinner.fail(text && color_1.colors.redBright(text));
38 }
39 warn(text) {
40 this.spinner.fail(text && color_1.colors.yellowBright(text));
41 }
42 stop() {
43 this.spinner.stop();
44 }
45 start(text) {
46 if (this.enabled) {
47 this.spinner.start(text);
48 }
49 }
50}
51exports.Spinner = Spinner;