How can I reuse npm spinner functionality

I am trying to add a spinner to my CLI, but I am having a hard time reusing a spinner that is present in npm

and it is displayed when npm

making HTTP requests (for example in npm install

).

From what I understand, this bit of code is responsible for creating the actual counter.

Apparently, this is what char-spinner is used for , and here is its most basic example:

var spinner = require("char-spinner")

// All options are optional
// even the options argument itself is optional
spinner()

      

When I run this, I am not printing anything to the screen ( process.stderr

).

What am I doing wrong and what is the correct way to use the repeater from npm

?

+3


source to share


1 answer


The spinner will show as long as the process still has something to run and won't just exit right away.

Try:



var spinner = require( 'char-spinner' );

spinner();

setTimeout( function() {}, 10000 );

      

+2


source







All Articles