Skip to content

Commit 87156ce

Browse files
farnabazsindresorhus
authored andcommitted
Fix support for nested styles (#335)
1 parent c25c32a commit 87156ce

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

source/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const stringReplaceAll = (string, substring, replacer) => {
1010
let endIndex = 0;
1111
let returnValue = '';
1212
do {
13-
returnValue += string.substr(endIndex, index - endIndex) + replacer;
13+
returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
1414
endIndex = index + substringLength;
1515
index = string.indexOf(substring, endIndex);
1616
} while (index !== -1);

test/chalk.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test('support nesting styles', t => {
3737
test('support nesting styles of the same type (color, underline, bg)', t => {
3838
t.is(
3939
chalk.red('a' + chalk.yellow('b' + chalk.green('c') + 'b') + 'c'),
40-
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[33mb\u001B[31mc\u001B[39m'
40+
'\u001B[31ma\u001B[33mb\u001B[32mc\u001B[39m\u001B[31m\u001B[33mb\u001B[39m\u001B[31mc\u001B[39m'
4141
);
4242
});
4343

0 commit comments

Comments
 (0)