From f6ebbfe14c37fd166dae62ef743cb09689d4e6ed Mon Sep 17 00:00:00 2001 From: xiangshouding Date: Tue, 16 Dec 2014 16:17:42 +0800 Subject: [PATCH] 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); }); });