mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-10-31 12:00:08 +00:00 
			
		
		
		
	Remove setTheme dynamic require(...) that is problematic with webpack
This commit is contained in:
		
							parent
							
								
									9f3ace4470
								
							
						
					
					
						commit
						c018e0b1fb
					
				| @ -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); | ||||||
|  | |||||||
| @ -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) { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user