stripColor() - gracefully handle non-string input
This commit is contained in:
parent
0133342393
commit
50da33ff12
1 changed files with 1 additions and 1 deletions
2
chalk.js
2
chalk.js
|
|
@ -51,7 +51,7 @@ function init() {
|
||||||
chalk.styles = ansi;
|
chalk.styles = ansi;
|
||||||
|
|
||||||
chalk.stripColor = function (str) {
|
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');
|
chalk.supportsColor = require('has-color');
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue