Skip to content

Commit

Permalink
fix: add the color prop missing in the style processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Thanga-Ganapathy committed Apr 2, 2024
1 parent c162b6e commit be1f172
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-otters-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@opentf/cli-styles': minor
---

Fixed invalid normal text modifier.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ built
lib
.parcel-cache
.turbo
play.js
play.js

test.js
6 changes: 6 additions & 0 deletions __tests__/modifiers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,10 @@ describe('Modifiers', () => {
it('renders not strikethrough text', () => {
expect(style('$nos{text}')).toEqual('\x1B[29mtext\x1B[0m');
});

it('renders pink color text after dim, bold & nor', () => {
expect(style(`$pi.dim.bol.nor{-> Node.js process.version}`)).toEqual(
'\u001B[38;2;255;191;203m\u001B[22m-> Node.js process.version\u001B[0m'
);
});
});
7 changes: 4 additions & 3 deletions src/processStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,16 @@ export default function processStyles(styles: string) {
} else {
value = STANDARD_COLORS[style];
}
map.set('color', { value, code: FG_CODE });
map.set('color', { value, code: FG_CODE, color: value });
continue;
}

if (style === 'dim') {
if (map.has('color')) {
const obj = map.get('color');
map.set('color', {
value: dimColor(map.get('color').value),
code: FG_CODE,
...obj,
value: dimColor(obj.value),
dim: true,
});
} else {
Expand Down

0 comments on commit be1f172

Please sign in to comment.