diff --git a/examples/normal-usage.js b/examples/normal-usage.js index 2818741..3ceabd0 100644 --- a/examples/normal-usage.js +++ b/examples/normal-usage.js @@ -60,7 +60,11 @@ console.log("this is an input".input); console.log('Generic logging theme as file'.green.bold.underline); // Load a theme from file -colors.setTheme(__dirname + '/../themes/generic-logging.js'); +try { + colors.setTheme(require(__dirname + '/../themes/generic-logging.js')); +} catch (err) { + console.log(err); +} // outputs red text console.log("this is an error".error); diff --git a/lib/colors.js b/lib/colors.js index 790ffd4..96ed4a7 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -115,7 +115,7 @@ function applyStyle() { return str; } -function applyTheme (theme) { +colors.setTheme = function (theme) { for (var style in theme) { (function(style){ colors[style] = function(str){ @@ -132,21 +132,6 @@ function applyTheme (theme) { } } -colors.setTheme = function (theme) { - if (typeof theme === 'string') { - try { - colors.themes[theme] = require(theme); - applyTheme(colors.themes[theme]); - return colors.themes[theme]; - } catch (err) { - console.log(err); - return err; - } - } else { - applyTheme(theme); - } -}; - function init() { var ret = {}; Object.keys(styles).forEach(function (name) {