[6a3a178] | 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 | */
|
---|
| 9 | var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
---|
| 10 | if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
---|
| 11 | if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
---|
| 12 | return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
---|
| 13 | };
|
---|
| 14 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
---|
| 15 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
---|
| 16 | };
|
---|
| 17 | var _Spinner_isTTY;
|
---|
| 18 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 19 | exports.Spinner = void 0;
|
---|
| 20 | const ora_1 = __importDefault(require("ora"));
|
---|
| 21 | const color_1 = require("./color");
|
---|
| 22 | const tty_1 = require("./tty");
|
---|
| 23 | class Spinner {
|
---|
| 24 | constructor(text) {
|
---|
| 25 | /** When false, only fail messages will be displayed. */
|
---|
| 26 | this.enabled = true;
|
---|
| 27 | _Spinner_isTTY.set(this, tty_1.isTTY());
|
---|
| 28 | this.spinner = ora_1.default({
|
---|
| 29 | text,
|
---|
| 30 | // The below 2 options are needed because otherwise CTRL+C will be delayed
|
---|
| 31 | // when the underlying process is sync.
|
---|
| 32 | hideCursor: false,
|
---|
| 33 | discardStdin: false,
|
---|
| 34 | isEnabled: __classPrivateFieldGet(this, _Spinner_isTTY, "f"),
|
---|
| 35 | });
|
---|
| 36 | }
|
---|
| 37 | set text(text) {
|
---|
| 38 | this.spinner.text = text;
|
---|
| 39 | }
|
---|
| 40 | get isSpinning() {
|
---|
| 41 | return this.spinner.isSpinning || !__classPrivateFieldGet(this, _Spinner_isTTY, "f");
|
---|
| 42 | }
|
---|
| 43 | succeed(text) {
|
---|
| 44 | if (this.enabled) {
|
---|
| 45 | this.spinner.succeed(text);
|
---|
| 46 | }
|
---|
| 47 | }
|
---|
| 48 | fail(text) {
|
---|
| 49 | this.spinner.fail(text && color_1.colors.redBright(text));
|
---|
| 50 | }
|
---|
| 51 | stop() {
|
---|
| 52 | this.spinner.stop();
|
---|
| 53 | }
|
---|
| 54 | start(text) {
|
---|
| 55 | if (this.enabled) {
|
---|
| 56 | this.spinner.start(text);
|
---|
| 57 | }
|
---|
| 58 | }
|
---|
| 59 | }
|
---|
| 60 | exports.Spinner = Spinner;
|
---|
| 61 | _Spinner_isTTY = new WeakMap();
|
---|