einaros / tinycolor

a to-the-point color module for node
18 stars 4 forks source link

Multiple instances fails to load #5

Open walling opened 11 years ago

walling commented 11 years ago

This module fails to load, if it's already loaded by another module, on this line: https://github.com/einaros/tinycolor/blob/master/tinycolor.js#L32

The issue is that the properties can not be overwritten twice. Is it possible to include a check, if this module is already loaded, and if that is the case, do nothing?

walling commented 11 years ago

Quick-fix (needs to be implemented for all users of tinycolor):

if (typeof(''.bgDefault) !== 'string') {
  require('tinycolor');
}

However, this module seems unmaintained, and I'm switching to chalk. They don't extend String.prototype, which leads to issues like this one.