jbcarpanelli / spinnies

Node.js module to create and manage multiple spinners in command-line interface programs
MIT License
147 stars 32 forks source link

text is leaking #9

Open devmondo opened 5 years ago

devmondo commented 5 years ago

Hi, i don't know what is happening exactly, but i think the picture below explains it better than words.

image

jbcarpanelli commented 5 years ago

Hi @devmondo! Thanks for raising this issue. I'm not being able to reproduce it, but I believe that this might have something to do with using chalk (I noticed different colors for the Step: label and the rest of the text). This is basically because spinnies counts the number of characters in each spinner line to clean the stream, and is counting the color characters that chalk appends and preppends to the text. That being said, I'm pretty sure you will get rid of this bug just by avoiding using chalk to color the Step: label for now until I release a fix.

devmondo commented 5 years ago

hi @jcarpanelli , thanks for the prompt reply,

indeed i am using chalk to color parts as you said, i will disable it for now as you said until the fix.

thanks alot :)

jbcarpanelli commented 5 years ago

Hi, @devmondo! I've just released a new version, v0.4.0. Could you please confirm whether your issue has been fixed or not? If not, I'll have to ask you more info in order to reproduce it.

devmondo commented 5 years ago

Hi @jcarpanelli!

thanks a lot for the work, I made tests and it is better now, the text and color are not getting mangled like in the first picture I posted, but still text is leaking. if you look at the picture below you would see the word, started is leaking to the previous console lines.

please let me know how I can help with more info and I hope I am not wasting your time.

image

jbcarpanelli commented 5 years ago

Another question @devmondo! Are you adding line breaks to any spinner message using \n? Something such as:

spinner.add('foo', { text: 'hello!' });
spinners.update('foo', { text: `hello\nI'm\na\nspinner!` });

And last question: Is the Backround: PLEX-100-create case > background is finished started text in the first two lines of the first picture being printed by spinnies? If not, that might be the issue. If any spinner is active, you shouldn't write the stderr/stdout without using spinnies, that's the main reason of having the non-spinnable status option (and btw, this is by design).

devmondo commented 5 years ago

@jcarpanelli , thanks a lot for the detailed answer!

yes, you are correct, on both counts. I am using a new line in spinnies at the end of the sentence.

and Background: PLEX-100-create case > background is finished started is indeed printed out with console.log and not spinnies.

I will try to convert all those console.log to non-spinnable ones and see if it solves the issue.

thanks a lot for the time and effort. i will work on it and let you know.

jbcarpanelli commented 5 years ago

Ok, great! I've just released v0.4.2 with a small fix when using \n characters. Now your problem should be only caused by those console.logs.