diff --git a/index.js b/index.js index c4b8adb..9754e1b 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,18 @@ var client = require('client') - , colors = require('colors') + , colors = !client && require('colors') + , has = require('has') + , is = require('is') module.exports = colorfill() function colorfill(){ /* istanbul ignore next */ - client && ['red', 'green', 'bold', 'grey', 'strip'].forEach(function(color) { - ('')[color] !== '' && Object.defineProperty(String.prototype, color, { - get: function () { + ['red', 'green', 'bold', 'grey', 'strip'].forEach(function(color) { + !is.str(String.prototype[color]) && Object.defineProperty(String.prototype, color, { + get: function() { return String(this) - } + } }) }) } + diff --git a/package.json b/package.json index 8f25918..c280eeb 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ }, "dependencies": { "client": "git+https://github.com/utilise/client.git", - "colors": "^1.1.0" + "colors": "^1.1.0", + "has": "git+https://github.com/utilise/has.git", + "is": "git+https://github.com/utilise/is.git" } } diff --git a/test.js b/test.js index b6dedf0..cd81a4e 100644 --- a/test.js +++ b/test.js @@ -1,5 +1,4 @@ var expect = require('chai').expect - , client = require('client') , colorfill = require('./') describe('colorfill', function() {