From 119291449cd03a11cdeda9e37cf718a69a012896 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Tue, 1 Dec 2015 19:35:24 -0800 Subject: [PATCH] use chalk for base reporter colors; closes #1200 --- lib/reporters/base.js | 42 ++++++++++++++++++++++-------------------- package.json | 3 ++- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/lib/reporters/base.js b/lib/reporters/base.js index bb107ba229..c74b071f36 100644 --- a/lib/reporters/base.js +++ b/lib/reporters/base.js @@ -7,6 +7,8 @@ var diff = require('diff'); var ms = require('../ms'); var utils = require('../utils'); var supportsColor = process.browser ? null : require('supports-color'); +var chalk = require('chalk'); +chalk.enabled = supportsColor; /** * Expose `Base`. @@ -50,25 +52,25 @@ exports.inlineDiffs = false; */ exports.colors = { - pass: 90, - fail: 31, - 'bright pass': 92, - 'bright fail': 91, - 'bright yellow': 93, - pending: 36, - suite: 0, - 'error title': 0, - 'error message': 31, - 'error stack': 90, - checkmark: 32, - fast: 90, - medium: 33, - slow: 31, - green: 32, - light: 90, - 'diff gutter': 90, - 'diff added': 32, - 'diff removed': 31 + pass: chalk.gray, + fail: chalk.red, + 'bright pass': chalk.green.bold, + 'bright fail': chalk.red.bold, + 'bright yellow': chalk.yellow.bold, + pending: chalk.cyan, + suite: chalk.white, + 'error title': chalk.gray, + 'error message': chalk.red, + 'error stack': chalk.white, + checkmark: chalk.green, + fast: chalk.gray, + medium: chalk.yellow, + slow: chalk.red, + green: chalk.green, + light: chalk.white.bold, + 'diff gutter': chalk.gray, + 'diff added': chalk.green, + 'diff removed': chalk.red }; /** @@ -103,7 +105,7 @@ var color = exports.color = function(type, str) { if (!exports.useColors) { return String(str); } - return '\u001b[' + exports.colors[type] + 'm' + str + '\u001b[0m'; + return '\u001b[' + exports.colors[type](str) + '\u001b[0m'; }; /** diff --git a/package.json b/package.json index c4fdddfffb..cf5152da56 100644 --- a/package.json +++ b/package.json @@ -274,6 +274,7 @@ "test": "make test-all" }, "dependencies": { + "chalk": "0.4.0", "commander": "2.3.0", "debug": "2.2.0", "diff": "1.4.0", @@ -312,4 +313,4 @@ "url": "https://raw.github.com/mochajs/mocha/master/LICENSE" } ] -} \ No newline at end of file +}