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?
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 );