loopj/commonjs-ansi-color — pull request #7 by ollieparsley (2012-04-13 07:47:11+00:00)
Title: Added a simple function to add color into an existing string

Added a simple function to add color into an existing string. Useful if the text is generated in another module etc. Has a try/catch block to trap invalid regex. Example:

var text = 'success: this is a string. But oh look! There is an Error: what are we going to do?';
text = color.replace(text, 'error:', 'red');
text = color.replace(text, 'success:', 'green');