source: trip-planner-front/node_modules/@angular-devkit/build-angular/src/utils/spinner.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.1 KB
Line 
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 */
9var __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};
14var __importDefault = (this && this.__importDefault) || function (mod) {
15 return (mod && mod.__esModule) ? mod : { "default": mod };
16};
17var _Spinner_isTTY;
18Object.defineProperty(exports, "__esModule", { value: true });
19exports.Spinner = void 0;
20const ora_1 = __importDefault(require("ora"));
21const color_1 = require("./color");
22const tty_1 = require("./tty");
23class 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}
60exports.Spinner = Spinner;
61_Spinner_isTTY = new WeakMap();
Note: See TracBrowser for help on using the repository browser.