chalk / slice-ansi

Slice a string with ANSI escape codes
MIT License
47 stars 21 forks source link

Handle slicing of links (#32) #34

Closed dspasojevic closed 1 year ago

dspasojevic commented 3 years ago

I'll close this to work out why test fail in CI but not locally.

dspasojevic commented 3 years ago

I'm not sure I understand the expected behavior of the failing test cases.

In iterm2, the expected and actual value for the third assertion in doesn't add extra escapes is:

\\u001b[31m\\u001b[30m\\u001b[43m RUN\\u001b[49m\\u001b[39m

the actual value produced is the same and the test passes. This kind of makes sense given the input string. Then both the foreground and background are cleared. None of the additional escape codes (for ${chalk.green('test')}) are included.

In the CI system, the actual version is:

\\u001b[31m RUN\\u001b[39m

and the expected value is:

\\u001b[31m RUN

I think that part of this is because the terminal exposed to the CI system supports fewer capabilities (i.e. doesn't support background yellow or foreground black). So I can understand why there are fewer codes that set the colors. I don't understand why the expected value has no codes to clear the foreground color.

Wouldn't the expectation be that [31m is cleared with a corresponding [39m?

sindresorhus commented 3 years ago

I haven't worked on this package for a long time, so I, unfortunately, don't have any answers for you. It might give some answers to git blame the lines and look at the PR(s) that introduced it.

sindresorhus commented 1 year ago

Closing for lack of activity.