How to use the Spinner function from clui

Find comprehensive JavaScript clui.Spinner code examples handpicked from public code repositorys.

clui.Spinner is a utility class for generating and rendering a spinner animation in the command line interface.

133
134
135
136
137
138
139
140
141

initEvents() {
    var inst = this.modclean;

    let progressBar = new clui.Progress(40),
        spinner = new clui.Spinner('Loading...'),
        showProgress = true;

    if(!process.stdout.isTTY || program.interactive || !program.progress || program.verbose) showProgress = false;
fork icon15
star icon372
watch icon7

2
3
4
5
6
7
8
9
10
11
const clear       = require('clear');
const CLI         = require('clui');
const figlet      = require('figlet');
const inquirer    = require('inquirer');
const Preferences = require('preferences');
const Spinner     = CLI.Spinner;
const fs          = require('fs-extra');
const files       = require('./lib/files');
const argv        = require('minimist')(process.argv.slice(2));
const cwd = files.getCurrentDirectoryBase()
fork icon11
star icon90
watch icon6

+ 15 other calls in file

How does clui.Spinner work?

clui.Spinner is a constructor function that creates a new Spinner object with configurable properties such as spinner frames, text color, and speed. The Spinner object can be started, stopped, and reset, and it displays a rotating spinner animation on the terminal.

18
19
20
21
22
23
24
25
26
27
var chalk = require('chalk');
var clear = require('clear');
var CLI = require('clui');
var figlet = require('figlet');
var inquirer = require('inquirer');
var Spinner = CLI.Spinner;
var _ = require('lodash');
var files = require('./lib/files');
var optional = require('optional');
var gpClient = null;
fork icon7
star icon18
watch icon2

+ 15 other calls in file

3
4
5
6
7
8
9
10
11
12
var clear       = require('clear');
var CLI         = require('clui');
var figlet      = require('figlet');
var inquirer    = require('inquirer');
var Preferences = require('preferences');
var Spinner     = CLI.Spinner;
var GitHubApi   = require('github');
var _           = require('lodash');
var git         = require('simple-git')();
var touch       = require('touch');
fork icon11
star icon9
watch icon2

+ 9 other calls in file

Ai Example

1
2
3
4
5
6
7
8
9
const clui = require("clui");

const spinner = new clui.Spinner("Loading...");
spinner.start();

setTimeout(() => {
  spinner.stop();
  console.log("Done!");
}, 3000);

In this example, a new Spinner object is created with a label of 'Loading...', and then started using the start() method. After 3 seconds (simulated using setTimeout()), the spinner is stopped using the stop() method and a message is printed to the console.

15
16
17
18
19
20
21
22
23
24
      horizontalLayout: 'default',
    })
  )
)

const Spinner = CLI.Spinner
const status = new Spinner('Generating files...', [
  '⣾',
  '⣽',
  '⣻',
fork icon2
star icon9
watch icon3

+ 3 other calls in file

118
119
120
121
122
123
124
125
126
127
let destination = `./${moduleName}`

if (!fs.existsSync(destination))
  fs.mkdirSync(destination);

let spinner = new clui.Spinner('Copying Files', ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷']);
spinner.start();

await (async _ => (
  new Promise((resolve, reject) =>
fork icon1
star icon8
watch icon1

+ 3 other calls in file

25
26
27
28
29
30
31
32
33
34
}
clear();
dragoon();

const CLI = require('clui');
const Spinner = CLI.Spinner;

function spinner(params) {
    var countdown = new Spinner('Exiting to main menu in 3 seconds...  ', ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']);
    countdown.start();
fork icon1
star icon3
watch icon3

+ 13 other calls in file

9
10
11
12
13
14
15
16
17
18
const { parseEmojis } = require('../utils/ascii')

/* ----------------------------------------- *
        Private
* ----------------------------------------- */
const connectingSpinner = new Spinner('Connecting to chat')
const cursor = new Cursor(1, 1)

// log : String -> Promise
const log = (...info) => {
fork icon0
star icon5
watch icon2

+ 11 other calls in file

95
96
97
98
99
100
101
102
103
104
    console.log(table.toString());     
    console.log('\n');        

},
startSpinner: (statusMessage) => {
    const Spinner = clui.Spinner;
    var spinner = new Spinner(statusMessage, ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷']);
    spinner.start();
    return spinner;
}      
fork icon0
star icon1
watch icon1

+ 13 other calls in file

14
15
16
17
18
19
20
21
22
23
        name: 'confirm',
        default: false
});

if (answer.confirm) {
        const spinner = new clui.Spinner('Cleaning up database...');
        spinner.start();

        await Export.deleteMany({});
        await sleep(1);
fork icon1
star icon3
watch icon2

26
27
28
29
30
31
32
33
34
35
36
37
const replace = require('replace-in-file');


/**
 * Clui spinner instance
 */
const spinner = clui.Spinner;


/**
 * Custom progress message and spinner
 */
fork icon0
star icon6
watch icon0

151
152
153
154
155
156
157
158
159
160
161
 * Products and Prices are sorted by ID.
 *
 * @return {Object}
 */
async function getRemoteConfig() {
  const loadingSpinner = new Spinner('Loading remote configuration from Stripe...');
  loadingSpinner.start();


  const productList = await getStripeProductList();
  const priceList = await getStripePriceList();
fork icon0
star icon1
watch icon0

85
86
87
88
89
90
91
92
93
94
// }

// updatePbBar()


// const Spinner = clui.Spinner
// var countdown = new Spinner('Exiting in 10 seconds...  ', ['⣾','⣽','⣻','⢿','⡿','⣟','⣯','⣷'])
// countdown.start()

// var number = 10
fork icon0
star icon0
watch icon0

438
439
440
441
442
443
444
445
446
447
return new Promise((resolve, reject) => {
  let returnSize = 0
  let countNeeded = backupPathArray.length
  log(chalk.green("need " + countNeeded))
  let count = 0
  let spinner = new clui.Spinner('Calculating...')
  spinner.start()
  backupPathArray.forEach((pth) => {
    getSize(pth, (err, size) => {
      if (err) {
fork icon0
star icon0
watch icon0

8
9
10
11
12
13
14
15
16
17
18
19
const { TS_REPO_URL } = require('../constants');


const initTsBoilerplate = async ({
  path: initPath, docker, gitlab, npmi,
}) => {
  const progress = new Spinner('Ensure dir..', ['⣾', '⣽', '⣻', '⢿', '⡿', '⣟', '⣯', '⣷']);
  progress.start();
  await fs.ensureDir(initPath);


  progress.message('Cloning repo...');
fork icon0
star icon0
watch icon0

3
4
5
6
7
8
9
10
11
12
13
14
15


const files = require('./lib/files')
const inquirer  = require('./lib/inquirer')


const CLI         = require('clui')
const Spinner     = CLI.Spinner
const status = new Spinner()


const task1 = null
const task2 = null
fork icon0
star icon0
watch icon0

10
11
12
13
14
15
16
17
18
const inquirer      = require('inquirer')
const path          = require('path')
const pkg           = require('./package.json')

const conf          = new Configstore(pkg.name)
const Spinner       = CLI.Spinner

// Our Libraries
const TranslationMemory = require('./lib/translation-memory')
fork icon0
star icon0
watch icon0

+ 13 other calls in file