From f6ebbfe14c37fd166dae62ef743cb09689d4e6ed Mon Sep 17 00:00:00 2001 From: xiangshouding Date: Tue, 16 Dec 2014 16:17:42 +0800 Subject: [PATCH 1/2] fix --no-color is not work --- lib/colors.js | 3 +++ lib/extendStringPrototype.js | 9 ++------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/lib/colors.js b/lib/colors.js index 59898de..15b3c19 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -48,6 +48,9 @@ colors.stripColors = colors.strip = function(str){ var stylize = colors.stylize = function stylize (str, style) { + if (!colors.enabled) { + return str+''; + } return ansiStyles[style].open + str + ansiStyles[style].close; } diff --git a/lib/extendStringPrototype.js b/lib/extendStringPrototype.js index b6b5b03..bbb9bcc 100644 --- a/lib/extendStringPrototype.js +++ b/lib/extendStringPrototype.js @@ -1,5 +1,4 @@ -var colors = require('./colors'), - styles = require('./styles'); +var colors = require('./colors'); module['exports'] = function () { @@ -18,10 +17,6 @@ module['exports'] = function () { } }; - var stylize = function stylize (str, style) { - return styles[style].open + str + styles[style].close; - } - addProperty('strip', function () { return colors.strip(this); }); @@ -60,7 +55,7 @@ module['exports'] = function () { var x = Object.keys(colors.styles); x.forEach(function (style) { addProperty(style, function () { - return stylize(this, style); + return colors.stylize(this, style); }); }); From 1774321751c0366908f181992cf6ee780f7b8aee Mon Sep 17 00:00:00 2001 From: xiangshouding Date: Fri, 23 Jan 2015 21:59:24 +0800 Subject: [PATCH 2/2] add an blank line --- lib/colors.js | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/colors.js b/lib/colors.js index 15b3c19..fe6202d 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -51,6 +51,7 @@ var stylize = colors.stylize = function stylize (str, style) { if (!colors.enabled) { return str+''; } + return ansiStyles[style].open + str + ansiStyles[style].close; }