Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I reuse npm's spinner functionality

I'm trying to add a spinner to my CLI, but I'm finding it difficult to reuse the spinner that's present in npm and is visible when npm is making HTTP requests (like in npm install).

From what I understand, this bit of code is responsible for making an actual spinner.

Apparently the char-spinner package is used for that and here's its most basic example:

var spinner = require("char-spinner")

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

When I run that, however, I don't get anything printed on the screen (process.stderr).

What am I doing wrong and what's the right way to reuse the spinner from npm?

like image 761
shime Avatar asked Jun 08 '26 00:06

shime


1 Answers

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

Try:

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

spinner();

setTimeout( function() {}, 10000 );
like image 118
go-oleg Avatar answered Jun 10 '26 17:06

go-oleg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!