From 0da00b2e321bd4c7782439182ab65cc2f1c5c259 Mon Sep 17 00:00:00 2001 From: DABH Date: Fri, 16 Feb 2018 14:32:59 -0800 Subject: [PATCH] Update colors.js Setting a theme using a dynamic require is bad practice and causes lots of problems. In case anyone is using that "feature," though, we return a warning that very explicitly tells them the (very simple) change they need to make to their code. --- lib/colors.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/colors.js b/lib/colors.js index 96ed4a7..2238270 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -116,6 +116,13 @@ function applyStyle() { } colors.setTheme = function (theme) { + if (typeof theme === 'string') { + console.log('colors.setTheme now only accepts an object, not a string. ' + + 'If you are trying to set a theme from a file, it is now your (the caller\'s) responsibility to require the file. ' + + 'The old syntax looked like colors.setTheme(__dirname + \'/../themes/generic-logging.js\'); ' + + 'The new syntax looks like colors.setTheme(require(__dirname + \'/../themes/generic-logging.js\'));'); + return; + } for (var style in theme) { (function(style){ colors[style] = function(str){ @@ -169,4 +176,4 @@ for (var map in colors.maps) { })(map) } -defineProps(colors, init()); \ No newline at end of file +defineProps(colors, init());