UNPKG

@redocly/cli

Version:

[@Redocly](https://redocly.com) CLI is your all-in-one OpenAPI utility. It builds, manages, improves, and quality-checks your OpenAPI descriptions, all of which comes in handy for various phases of the API Lifecycle. Create your own rulesets to make API g

40 lines 1.24 kB
import * as process from 'node:process'; import { logger } from '@redocly/openapi-core'; const SPINNER_FRAMES = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; export class Spinner { constructor() { this.frames = SPINNER_FRAMES; this.currentFrame = 0; this.intervalId = null; this.message = ''; } showFrame() { logger.info('\r' + this.frames[this.currentFrame] + ' ' + this.message); this.currentFrame = (this.currentFrame + 1) % this.frames.length; } start(message) { if (this.message === message) { return; } this.message = message; // If we're not in a TTY, don't display the spinner. if (!process.stderr.isTTY) { logger.info(`${message}...\n`); return; } if (this.intervalId === null) { this.intervalId = setInterval(() => { this.showFrame(); }, 100); } } stop() { if (this.intervalId !== null) { clearInterval(this.intervalId); this.intervalId = null; logger.info('\r'); } this.message = ''; } } //# sourceMappingURL=spinner.js.map