opencollective / opencollective-cli

Command Line Interface for Open Collective
MIT License
17 stars 12 forks source link

Improves ansi escape sequence regex #13

Open misterdev opened 5 years ago

misterdev commented 5 years ago

It now matches also sequences with one digit \x1b[_m

Escape sequence Text attributes
\x1b[0m All attributes off(color at startup)
\x1b[1m Bold on(enable foreground intensity)
\x1b[4m Underline on
\x1b[5m Blink on(enable background intensity)
znarf commented 5 years ago

@misterdev Which issue does that fix? Is that in the opencollective postinstall scenario?

misterdev commented 5 years ago

Working with the print script sometimes the text is not well center. The problem is that chalk.bold (used here) adds the escape sequence \x1b[1m to the string.

Inside the print this sequence is not matched by the regex and it's not removed. This causes the leftPaddingLength to be incorrect resulting in an incorrect centering.

Before:

52351182-7ca9b300-2a2a-11e9-87e7-0c90105ac49f

After:

52376323-19d40e00-2a62-11e9-8eab-1e22f51f648f
misterdev commented 3 years ago

Hi @znarf, sorry for the ping, do you think this will be considered? Otherwise, we can close it :)