Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Fix the color wrap function #186

merged 1 commit into from

3 participants


The wrap color function isn't working properly, allowing invalid color names for color and not taking reset_color into account.
This commit forces input validation against the list of color codes: if color is an invalid color entry, the function returns only the unmodified text; if reset_color is invalid, it is set to 'reset'.


Welcome to GitHub, @cattode! For further reference, please also state what was done to "fix" the issue in your summary and it doesn't hurt to go in depth a little more. For example, in this case one might say the following:

The wrap color function isn't working properly allowing invalid color names for both color and reset_color. This commit forces input validation against the list of color codes, returning only the unmodified text upon receiving invalid color entries.

A statement like this not only states the issue clearly, it also states the intended result of the solution. This way even if this commit isn't pulled, the repository owner will still be notified of the issue and made aware of a potential solution (especially for more complex issues).


Yeah sorry, you're right, I don't use github often so I'm not very used to making pull requests yet. I've edited my message according to your recommendations!


Yeah, it boggles how the original version even got there, this definitely looks like a step forward, thanks :-)

@martynsmith martynsmith merged commit 83d42a3 into martynsmith:master
@cattode cattode deleted the unknown repository branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Sep 3, 2013
  1. @cattode

    Fix the color wrap function

    cattode authored
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 2 deletions.
  1. +5 −2 lib/colors.js
7 lib/colors.js
@@ -20,8 +20,11 @@ codes = { = codes;
function wrap(color, text, reset_color) {
- reset_color = typeof(a) != 'undefined' ? a : 'reset';
- return codes[color] + text + codes[reset_color];
+ if(codes[color]) {
+ text = codes[color] + text;
+ text += (codes[reset_color]) ? codes[reset_color] : codes['reset'];
+ }
+ return text;
exports.wrap = wrap;
Something went wrong with that request. Please try again.