forked from orbit-oss/chalk
don't output escape codes if the input is empty
This commit is contained in:
parent
879defda72
commit
492d63916c
2 changed files with 5 additions and 1 deletions
2
chalk.js
2
chalk.js
|
|
@ -38,7 +38,7 @@ function init() {
|
|||
|
||||
return self._styles.reduce(function (str, name) {
|
||||
var code = ansi[name];
|
||||
return code.open + (str || '') + code.close;
|
||||
return str ? code.open + str + code.close : '';
|
||||
}, str);
|
||||
}, styles);
|
||||
|
||||
|
|
|
|||
4
test.js
4
test.js
|
|
@ -37,6 +37,10 @@ describe('chalk', function () {
|
|||
it('should support falsy values', function () {
|
||||
assert.equal(chalk.red(0), '\x1b[31m0\x1b[39m');
|
||||
});
|
||||
|
||||
it('don\'t output escape codes if the input is empty', function () {
|
||||
assert.equal(chalk.red(), '');
|
||||
});
|
||||
});
|
||||
|
||||
describe('chalk.enabled', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue