mimosa icon indicating copy to clipboard operation
mimosa copied to clipboard

Suppress ANSI when output redirected

Open chrylis opened this issue 9 years ago • 6 comments

Mimosa has nice colored output which is helpful for identifying warnings during development, but it outputs ANSI escape codes unconditionally, which leaves CI logs and similar output captures with odd stray characters. It would be helpful to act like GNU ls and grep and suppress color output if !isatty(stdout).

chrylis avatar Feb 16 '15 01:02 chrylis

I can take a look at something like that. There was a thread about something like this on the Google group and the poster had a great solution. Great use of profiles.

https://groups.google.com/forum/m/#!topic/mimosajs/zEO86-2a7kg

dbashford avatar Feb 16 '15 01:02 dbashford

This is the sort of thing that's fairly universal (redirected output should just be the plain text), and I really do suggest having it as built-in behavior. (I have absolutely no idea how to do that in Node, though.)

chrylis avatar Feb 16 '15 01:02 chrylis

Well, with 2 or 3 minutes of work the profile solution would solve your problem. But yeah, worthwhile feature. Not sure how to figure out if something isn't going to stdout. Will poke around.

dbashford avatar Feb 16 '15 02:02 dbashford

Going to just leave this here for later: http://stackoverflow.com/questions/7080458/test-whether-the-actual-output-is-a-terminal-or-not-in-node-js

dbashford avatar Feb 16 '15 02:02 dbashford

Is the message-formatting code (specifically that applies the coloring) centralized, or are there multiple components that each handle formatting for different message types?

chrylis avatar Feb 16 '15 03:02 chrylis

Centralized. https://github.com/dbashford/logmimosa

logmimosa is attached to the mimosaConfig object passed to the modules: https://github.com/dbashford/mimosa-ember-module-import/blob/master/src/index.js#L64

Module can choose to import logmimosa directly, but I've not seen one that does.

So, once the feature is added and mimosa is upgraded to contain it (logmimosa is a dependency of mimosa) then all the modules will take advantage.

At this point, except for critical bugs, I'm postponing feature stuff that effects core until I've wrapped up testing/javascript translation of mimosa core. This feature is definitely key enough to make the 3.0 release. Once I've knocked out testing it'll be in the group of things that I take care of before releasing.

Thanks for the suggestion!

dbashford avatar Feb 16 '15 03:02 dbashford