Remove setTheme dynamic require(...) that is problematic with webpack

This commit is contained in:
John Papandriopoulos 2017-09-29 15:49:30 -07:00
parent 9f3ace4470
commit c018e0b1fb
2 changed files with 6 additions and 17 deletions

View File

@ -60,7 +60,11 @@ console.log("this is an input".input);
console.log('Generic logging theme as file'.green.bold.underline); console.log('Generic logging theme as file'.green.bold.underline);
// Load a theme from file // 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 // outputs red text
console.log("this is an error".error); console.log("this is an error".error);

View File

@ -115,7 +115,7 @@ function applyStyle() {
return str; return str;
} }
function applyTheme (theme) { colors.setTheme = function (theme) {
for (var style in theme) { for (var style in theme) {
(function(style){ (function(style){
colors[style] = function(str){ 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() { function init() {
var ret = {}; var ret = {};
Object.keys(styles).forEach(function (name) { Object.keys(styles).forEach(function (name) {