dbashford / mimosa

A lightning-fast, modular, next generation browser development tool.
http://mimosa.io/
519 stars 34 forks source link

Suppress ANSI when output redirected #435

Open chrylis opened 9 years ago

chrylis commented 9 years ago

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).

dbashford commented 9 years ago

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

chrylis commented 9 years ago

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.)

dbashford commented 9 years ago

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 commented 9 years ago

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

chrylis commented 9 years ago

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

dbashford commented 9 years ago

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!