How to use cli-spinners - 10 common examples

To help you get started, we’ve selected a few cli-spinners examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kvz / invig / src / removeVariance.js View on Github external
input = input.replace(/^.*No license field.*\n/gm, '')
  input = input.replace(/^.*Already up-to-date.*\n/gm, '')
  input = input.replace(/^.*Building fresh packages.*\n/gm, '')
  input = input.replace(/^.*Fetching package.*\n/gm, '')
  input = input.replace(/^.*fsevents.*Excluding it from installation.*\n/gm, '')
  input = input.replace(/^.*fsevents.*incompatible with this module.*\n/gm, '')
  input = input.replace(/^.*Linking dependencies.*\n/gm, '')
  input = input.replace(/^.*peer dependency "es6-promise.*\n/gm, '')
  input = input.replace(/^.*Resolving packages.*\n/gm, '')
  input = input.replace(/^.*There appears to be trouble with your network connection.*\n/gm, '')
  input = input.replace(/Done in \d+\.\d+s/g, 'Done in X.Xs')
  input = input.replace(/\d+ms/g, 'XXms')
  input = input.replace(/yarn install v\d+\.\d+\.\d+/g, 'yarn install vX.X.X')

  // @todo: Remove this hack when scrolex no longer adds trailing spinner frames:
  cliSpinner.frames.forEach(frame => {
    while (input.includes(frame)) {
      // console.log({input, frame})
      input = input.replace(frame, '---spinnerframe---')
    }
  })

  return input
}
github YMFE / ykit / lib / utils / ora.js View on Github external
(0, _classCallCheck3.default)(this, Ora);

        if (typeof options === 'string') {
            options = {
                text: options
            };
        }

        this.options = extend(true, {
            text: '',
            color: 'cyan',
            stream: process.stderr
        }, options);

        var sp = this.options.spinner;
        this.spinner = (typeof sp === 'undefined' ? 'undefined' : (0, _typeof3.default)(sp)) === 'object' ? sp : process.platform === 'win32' ? cliSpinners.line : cliSpinners[sp] || cliSpinners.dots; // eslint-disable-line no-nested-ternary

        if (this.spinner.frames === undefined) {
            throw new Error('Spinner must define `frames`');
        }

        this.text = this.options.text;
        this.color = this.options.color;
        this.interval = this.options.interval || this.spinner.interval || 100;
        this.stream = this.options.stream;
        this.id = null;
        this.frameIndex = 0;
        this.enabled = this.options.enabled || this.stream && this.stream.isTTY && !process.env.CI;
    }
github YMFE / ykit / src / utils / ora.js View on Github external
text: options
            };
        }

        this.options = extend(true, {
            text: '',
            color: 'cyan',
            stream: process.stderr
        }, options);

        const sp = this.options.spinner;
        this.spinner = typeof sp === 'object'
            ? sp
            : (process.platform === 'win32'
                ? cliSpinners.line
                : (cliSpinners[sp] || cliSpinners.dots)); // eslint-disable-line no-nested-ternary

        if (this.spinner.frames === undefined) {
            throw new Error('Spinner must define `frames`');
        }

        this.text = this.options.text;
        this.color = this.options.color;
        this.interval = this.options.interval || this.spinner.interval || 100;
        this.stream = this.options.stream;
        this.id = null;
        this.frameIndex = 0;
        this.enabled = this.options.enabled || ((this.stream && this.stream.isTTY) && !process.env.CI);
    }
    frame() {
github enquirer / enquirer / recipes / spinner-choices.js View on Github external
const indicator = (prompt, choice, index, options) => {
  if (choice.spinner) return choice.spinner;
  let opts = { ...choice, ...options };
  let ind = choice.origIndicator || (choice.origIndicator = choice.indicator);
  let framerate = opts.framerate || opts.interval || spinners.dots.interval;
  let colorRate = opts.colorRate || framerate;
  let animation = choice.spinner = new Animate({
    maxTime: 5000,
    framerate,
    frames: opts.frames || spinners.dots.frames,
    index,
    onStart() {
      choice.completing = true;
      choice.colorFrame = 0;
      choice.colorInt = setInterval(() => {
        choice.colorFrame++;
      }, colorRate);
    },
    async onUpdate() {
      let color = colors[animation.ele(keys, choice.colorFrame)];
      choice.indicator = color(animation.frame());
      await prompt.render();
    },
    onFail() {
      // choice.hint = prompt.styles.disabled('(cannot resolve choice)');
      // choice.disabled = true;
github moneyhub / navy / packages / navy / src / cli / updates.js View on Github external
/* @flow */

import chalk from 'chalk'
import readline from 'readline'
import {dots} from 'cli-spinners'
import {getNavy} from '../'
import table from '../util/table'
import hasUpdate from '../util/has-update'

const debug = require('debug')('navy:updates')

let spinnerIndex = 0
let spinnerFrame = dots.frames[0]

function renderStatus(status) {
  if (status == null) {
    return chalk.yellow(spinnerFrame) + ' ' + chalk.dim('Checking...')
  } else if (status === true) {
    return chalk.yellow('• Update available')
  } else if (status === 'UNKNOWN_REMOTE') {
    return chalk.red('• Not found')
  } else if (status === 'UNKNOWN_ERROR') {
    return chalk.red('• Internal error')
  } else if (status === 'NO_IMAGE') {
    return chalk.red('• No image for service')
  } else {
    return chalk.green('✔ Up to date')
  }
}
github musically-ut / appreciate / cli.js View on Github external
return api.getName(x);
            });

            spinnerNames.sort();

            const maxPadding = Math.max.apply(
                null,
                spinnerNames.map(x => {
                    return x.length;
                })
            );

            const multiSpinners = new Multispinner(spinnerNames, {
                clear: false,
                autoStart: true,
                frames: dotsSpinner.frames,
                interval: dotsSpinner.interval
            });

            let allModuleInfos = uniqueModuleInfos.map(x => {
                return makeTask(token, x, multiSpinners, maxPadding);
            });

            // Place checking for musically-ut/appreciate at the top of the
            // list for recovery afterwards.
            allModuleInfos.unshift(checkIsAppreciateAppreciated(token, multiSpinners));

            return Promise.all(allModuleInfos);
        })
        .then(allModuleInfosResolved => {
github YMFE / ykit / src / utils / ora.js View on Github external
options = {
                text: options
            };
        }

        this.options = extend(true, {
            text: '',
            color: 'cyan',
            stream: process.stderr
        }, options);

        const sp = this.options.spinner;
        this.spinner = typeof sp === 'object'
            ? sp
            : (process.platform === 'win32'
                ? cliSpinners.line
                : (cliSpinners[sp] || cliSpinners.dots)); // eslint-disable-line no-nested-ternary

        if (this.spinner.frames === undefined) {
            throw new Error('Spinner must define `frames`');
        }

        this.text = this.options.text;
        this.color = this.options.color;
        this.interval = this.options.interval || this.spinner.interval || 100;
        this.stream = this.options.stream;
        this.id = null;
        this.frameIndex = 0;
        this.enabled = this.options.enabled || ((this.stream && this.stream.isTTY) && !process.env.CI);
    }
    frame() {
github sindresorhus / ora / index.js View on Github external
set spinner(spinner) {
		this.frameIndex = 0;

		if (typeof spinner === 'object') {
			if (spinner.frames === undefined) {
				throw new Error('The given spinner must have a `frames` property');
			}

			this._spinner = spinner;
		} else if (process.platform === 'win32') {
			this._spinner = cliSpinners.line;
		} else if (spinner === undefined) {
			// Set default spinner
			this._spinner = cliSpinners.dots;
		} else if (cliSpinners[spinner]) {
			this._spinner = cliSpinners[spinner];
		} else {
			throw new Error(`There is no built-in spinner named '${spinner}'. See https://github.com/sindresorhus/cli-spinners/blob/master/spinners.json for a full list.`);
		}

		this._updateInterval(this._spinner.interval);
	}
github musically-ut / appreciate / cli.js View on Github external
});

            spinnerNames.sort();

            const maxPadding = Math.max.apply(
                null,
                spinnerNames.map(x => {
                    return x.length;
                })
            );

            const multiSpinners = new Multispinner(spinnerNames, {
                clear: false,
                autoStart: true,
                frames: dotsSpinner.frames,
                interval: dotsSpinner.interval
            });

            let allModuleInfos = uniqueModuleInfos.map(x => {
                return makeTask(token, x, multiSpinners, maxPadding);
            });

            // Place checking for musically-ut/appreciate at the top of the
            // list for recovery afterwards.
            allModuleInfos.unshift(checkIsAppreciateAppreciated(token, multiSpinners));

            return Promise.all(allModuleInfos);
        })
        .then(allModuleInfosResolved => {
github kvz / lanyon / src / executive.js View on Github external
const logUpdate   = require('log-update')
const cliSpinner  = require('cli-spinners').dots10
const logSymbols  = require('log-symbols')
const cliTruncate = require('cli-truncate')
const chalk       = require('chalk')
const spawnSync   = require('spawn-sync')
const osTmpdir    = require('os-tmpdir')
// const debug       = require('depurar')('lanyon')
const fs          = require('fs')
const spawn       = require('child_process').spawn
const _           = require('lodash')

class Executive {
  constructor () {
    this._opts = null
    this._cmd  = null

    this._types      = [ 'stdout', 'stderr' ]