-
-
Notifications
You must be signed in to change notification settings - Fork 274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible to use ora when logging things after the first initiation of a spinner? #49
Comments
I took the approach of logging out to a file instead. In my case, I'm running shell commands: some_command_here >> some.log 2>&1 The basic flow is:
I find this a good alternative to what is proposed, and the user experience is better. For example, what happens when you 'interrupt' so much that the spinner runs off the screen? |
I could understand that. As an alternative, I found I could do what I wanted to achieve with draftlog. I just re-made ora's functionality in draftlog, ending up in something like this. |
Ora always clears the last line in the TTY stream. It assumes it was the last to write to the stream, so if you write some lines yourself then you break that assumption. What you could do if you can control when you write to the stream is to call |
well, this isn't a perfect solution, but you can use this as a starting point to build a function that could handle it better. I cooked this up in like 5 mins. let buffer;
function logtext(text) {
buffer = text;
spinner.text = `${spinner.text}\n${text}`
}
spinner.start('initialized spinner');
logtext('something else');
setTimeout(() => {
spinner.succeed(`ended spinner\n${buffer}`);
process.exit();
}, 3500); |
As @novemberborn said, this works: const logInfo = (text) => {
spinner.clear();
spinner.frame();
console.log(text);
} |
…. Not really the best... uncertain how to fully implement this well, but this was very valuable in my guessing: sindresorhus/ora#49 (comment)
You can override |
If I initiate a spinner,
console.log
something after initiating it, and then end the spinner, it prints on a new line.Example:
How it ends up: http://i.imgur.com/ok6zSKZ.png
How I want it to end up: http://i.imgur.com/aBeERi0.png
The text was updated successfully, but these errors were encountered: