Skip to content

Commit

Permalink
use supports-color module
Browse files Browse the repository at this point in the history
To check if colors should be used or not.

It allows you to force colors through the use of command line flags.

See https://github.com/sindresorhus/supports-color/blob/2ae39320b7ca26c2803b4da531ed9bbcc40d78a3/index.js#L11
  • Loading branch information
gustav-olsen-groupone committed Feb 2, 2015
1 parent b9fcc4e commit 28599b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/report/common/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

var Report = require('../index');
var supportsColor = require('supports-color');

module.exports = {
watermarks: function () {
Expand All @@ -23,7 +24,7 @@ module.exports = {

colorize: function (str, clazz) {
/* istanbul ignore if: untestable in batch mode */
if (process.stdout.isTTY) {
if (supportsColor) {
switch (clazz) {
case 'low' : str = '\033[91m' + str + '\033[0m'; break;
case 'medium': str = '\033[93m' + str + '\033[0m'; break;
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
"fileset": "0.1.x",
"which": "1.0.x",
"async": "0.9.x",
"supports-color": "1.2.x",
"abbrev": "1.0.x",
"wordwrap": "0.0.x",
"resolve": "0.7.x",
Expand Down

0 comments on commit 28599b5

Please sign in to comment.