Skip to content

Commit a766c57

Browse files
fix: error in non tty environments (#5)
1 parent 420993a commit a766c57

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
]
4848
},
4949
"dependencies": {
50-
"terminal-columns": "^1.4.0",
50+
"terminal-columns": "^1.4.1",
5151
"type-flag": "^2.0.0"
5252
},
5353
"devDependencies": {

pnpm-lock.yaml

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/render-help/renderers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,17 @@ export class Renderers {
1919
}
2020

2121
bold(text: string) {
22-
return `\u001B[1m${text}\u001B[22m`;
22+
return stdoutHasColors
23+
? `\u001B[1m${text}\u001B[22m`
24+
: text.toLocaleUpperCase();
2325
}
2426

2527
indentText({ text, spaces }: { text: string; spaces: number }) {
2628
return text.replace(/^/gm, ' '.repeat(spaces));
2729
}
2830

2931
heading(text: string) {
30-
return stdoutHasColors ? this.bold(text) : text.toLocaleUpperCase();
32+
return this.bold(text);
3133
}
3234

3335
section({

tests/help.spec.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ afterEach(() => {
1919
mockConsoleLog.mockRestore();
2020
});
2121

22+
afterAll(() => {
23+
mockProcessExit.mockRestore();
24+
});
25+
2226
describe('show help', () => {
2327
test('empty cli', () => {
2428
cli(

0 commit comments

Comments
 (0)