Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Rev | Line | |
---|
[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 __importDefault = (this && this.__importDefault) || function (mod) {
|
---|
| 10 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
---|
| 11 | };
|
---|
| 12 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 13 | exports.Spinner = void 0;
|
---|
| 14 | const ora_1 = __importDefault(require("ora"));
|
---|
| 15 | const color_1 = require("./color");
|
---|
| 16 | class Spinner {
|
---|
| 17 | constructor(text) {
|
---|
| 18 | /** When false, only fail messages will be displayed. */
|
---|
| 19 | this.enabled = true;
|
---|
| 20 | this.spinner = ora_1.default({
|
---|
| 21 | text,
|
---|
| 22 | // The below 2 options are needed because otherwise CTRL+C will be delayed
|
---|
| 23 | // when the underlying process is sync.
|
---|
| 24 | hideCursor: false,
|
---|
| 25 | discardStdin: false,
|
---|
| 26 | });
|
---|
| 27 | }
|
---|
| 28 | set text(text) {
|
---|
| 29 | this.spinner.text = text;
|
---|
| 30 | }
|
---|
| 31 | succeed(text) {
|
---|
| 32 | if (this.enabled) {
|
---|
| 33 | this.spinner.succeed(text);
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | info(text) {
|
---|
| 37 | this.spinner.info(text);
|
---|
| 38 | }
|
---|
| 39 | fail(text) {
|
---|
| 40 | this.spinner.fail(text && color_1.colors.redBright(text));
|
---|
| 41 | }
|
---|
| 42 | warn(text) {
|
---|
| 43 | this.spinner.fail(text && color_1.colors.yellowBright(text));
|
---|
| 44 | }
|
---|
| 45 | stop() {
|
---|
| 46 | this.spinner.stop();
|
---|
| 47 | }
|
---|
| 48 | start(text) {
|
---|
| 49 | if (this.enabled) {
|
---|
| 50 | this.spinner.start(text);
|
---|
| 51 | }
|
---|
| 52 | }
|
---|
| 53 | }
|
---|
| 54 | exports.Spinner = Spinner;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.