From 50da33ff12f6d70f17aa1fdfb17b897d2a8b3127 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Sat, 12 Oct 2013 19:18:24 +0200 Subject: [PATCH] stripColor() - gracefully handle non-string input --- chalk.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chalk.js b/chalk.js index 17c6dba..9e508d0 100644 --- a/chalk.js +++ b/chalk.js @@ -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');