stripColor() - gracefully handle non-string input

This commit is contained in:
Sindre Sorhus 2013-10-12 19:18:24 +02:00
parent 0133342393
commit 50da33ff12

View file

@ -51,7 +51,7 @@ function init() {
chalk.styles = ansi;
chalk.stripColor = function (str) {
return str.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/g, '');
return typeof str === 'string' ? str.replace(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/g, '') : str;
};
chalk.supportsColor = require('has-color');