mirror of
				https://github.com/flynx/colors.js.git
				synced 2025-10-31 12:00:08 +00:00 
			
		
		
		
	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.
This commit is contained in:
		
							parent
							
								
									c018e0b1fb
								
							
						
					
					
						commit
						0da00b2e32
					
				| @ -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){ | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user