Skip to content

Commit 9ac5957

Browse files
committed
fix: Use optimal RegExp for styling within CLI
1 parent 89c0986 commit 9ac5957

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/cli/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ export const prependTabs = (value: string) =>
5858

5959
export const formatCliMessage = (value: string): string => {
6060
const tagToColorMap = {
61-
m: 'magenta',
6261
c: 'cyan',
6362
g: 'green',
63+
m: 'magenta',
6464
r: 'red',
6565
y: 'yellow',
6666
} as const;
67-
const regexp = new RegExp(`<((${Object.keys(tagToColorMap).join('|')}))>(.*?)</\\2>`, 'g');
67+
68+
const allTags = `[${Object.keys(tagToColorMap).join('')}]`;
69+
const regexp = new RegExp(`<((${allTags}))>(.*?)</\\2>`, 'g');
6870

6971
return stripIndent(value.replaceAll(regexp,
7072
(substring, _, tag: keyof typeof tagToColorMap, tagContents) => {

0 commit comments

Comments
 (0)