svenstaro/miniserve

ANSI color codes are printed when not a tty

stevenengler opened this issue · 2 comments

When the output of miniserve is written to a file or pipe, the ANSI color codes are still printed and the output looks like:

ESC[1mminiserveESC[0m v0.23.0
Bound to ESC[1;32m[::]:8080ESC[0m, ESC[1;32m0.0.0.0:8080ESC[0m
Serving path ESC[1;33m/fooESC[0m
Available at (non-exhaustive list):
    ESC[1;32mhttp://127.0.0.1:8080ESC[0m
    ESC[1;32mhttp://[::1]:8080ESC[0m

Most applications check if it's running in a tty and only show color codes when it is, and sometimes allow that behaviour to be overridden. For example cargo has CARGO_TERM_COLOR and --color. It would be nice if miniserve did so as well.

This should be fixed now, please check whether that works for you.

Works for me, thanks!