Skip to content

Commit

Permalink
fix: error in non tty environments (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Jan 24, 2022
1 parent 420993a commit a766c57
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
]
},
"dependencies": {
"terminal-columns": "^1.4.0",
"terminal-columns": "^1.4.1",
"type-flag": "^2.0.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/render-help/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ export class Renderers {
}

bold(text: string) {
return `\u001B[1m${text}\u001B[22m`;
return stdoutHasColors
? `\u001B[1m${text}\u001B[22m`
: text.toLocaleUpperCase();
}

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

heading(text: string) {
return stdoutHasColors ? this.bold(text) : text.toLocaleUpperCase();
return this.bold(text);
}

section({
Expand Down
4 changes: 4 additions & 0 deletions tests/help.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ afterEach(() => {
mockConsoleLog.mockRestore();
});

afterAll(() => {
mockProcessExit.mockRestore();
});

describe('show help', () => {
test('empty cli', () => {
cli(
Expand Down

0 comments on commit a766c57

Please sign in to comment.