groupon / assertive

Assertive is a terse yet expressive assertion library
BSD 3-Clause "New" or "Revised" License
21 stars 11 forks source link

Optional colors #9

Closed jkrems closed 10 years ago

jkrems commented 10 years ago

Addresses #8 - not all environments are fans of ansi colors.

johan commented 10 years ago

@EndangeredMassa Thoughts or opinions on the way this gets the job done? It's one of those sad problems to have, and also sad ways to address it, given the lack of a non-api-surface way of setting preferences like this. Lacking other input, I'm a +0, as I assume this does cause pain somewhere for some people.

A README mention of some sort would probably be in order, though.

jkrems commented 10 years ago

One possible other way to solve this that works at least for my use case is to check process.stdout.isTTY and auto-disable colors when it is either not present (e.g. in a browser) or is not true.

EndangeredMassa commented 10 years ago

I think that the process.stdout.isTTY solution would work best.

jkrems commented 10 years ago

Updated to just check for isTTY and disable colors if it's not true.

EndangeredMassa commented 10 years ago

Looks fine to me.

dbushong commented 10 years ago

Doesn't the chalk module handle all this stuff and more? (Or are you looking to avoid dependencies?)

jkrems commented 10 years ago

This module is browser friendly without being opinionated about bundling right now (e.g. it doesn't depend on browserify). Adding a dependency on chalk would change that (most likely).

johan commented 10 years ago

Yep, pretty sure this is the way to go – thanks!

johan commented 10 years ago

Released in v1.4.0. Seems github has commit message auto-close magic for "fixes #8" but not for "addresses #8". :-)

johan commented 10 years ago

Oh, that was a PR comment, never mind.