Skip to content

Commit

Permalink
Fixed option to force render on non TTY not working
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanPB committed Nov 18, 2021
1 parent c6e96c8 commit eb76237
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/render/ProgressBarRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ export class StreamProgressBarRenderer extends ProgressBarRenderer {
template: string,
tokens: TokenDict,
public readonly stream: WriteStream,
public readonly extra: { disableNonTTY?: boolean } = {}
public readonly extra: { enableNonTTY?: boolean } = {}
) {
super(template, tokens);
}

public render(bar: ProgressBarState) {
if (this.extra.disableNonTTY && !this.stream.isTTY) return
if (!this.extra.enableNonTTY && !this.stream.isTTY) return
this.stream.cursorTo(0)
this.stream.write(this.makeString(bar))
this.stream.clearLine(1)
Expand All @@ -72,13 +72,13 @@ export class StreamMultiProgressBarRenderer extends ProgressBarRenderer {
tokens: { [token: string]: Token },
public readonly stream: WriteStream,
private readonly bars: ProgressBarState[],
public readonly extra: { disableNonTTY?: boolean } = {}
public readonly extra: { enableNonTTY?: boolean } = {}
) {
super(template, tokens);
}

public render(bar: ProgressBarState) {
if (this.extra.disableNonTTY && !this.stream.isTTY) return
if (!this.extra.enableNonTTY && !this.stream.isTTY) return
const index = this.bars.indexOf(bar)
if (index === -1) return

Expand Down

0 comments on commit eb76237

Please sign in to comment.