Skip to content

Documentation / listr2 / DefaultRenderer

Class: DefaultRenderer

The definition of a ListrRenderer.

See

https://listr2.kilic.dev/renderer/renderer.html

Implements

Constructors

new DefaultRenderer(tasks, options, events)

new DefaultRenderer(tasks, options, events): DefaultRenderer

Parameters

tasks: ListrDefaultRendererTask[]

options: ListrDefaultRendererOptions

events: ListrEventManager

Returns

DefaultRenderer

Source

packages/listr2/src/renderer/default/renderer.ts:63

Properties

nonTTY

static nonTTY: boolean = false

designate whether this renderer can work in non-tty environments

Implementation of

ListrRenderer.nonTTY

Source

packages/listr2/src/renderer/default/renderer.ts:22


rendererOptions

static rendererOptions: ListrDefaultRendererOptions

designate renderer global options that is specific to the current renderer

Implementation of

ListrRenderer.rendererOptions

Source

packages/listr2/src/renderer/default/renderer.ts:23


rendererTaskOptions

static rendererTaskOptions: ListrDefaultRendererTaskOptions

designate renderer per task options that is specific to the current renderer

Implementation of

ListrRenderer.rendererTaskOptions

Source

packages/listr2/src/renderer/default/renderer.ts:42


prompt

private prompt: string

Source

packages/listr2/src/renderer/default/renderer.ts:46


activePrompt

private activePrompt: string

Source

packages/listr2/src/renderer/default/renderer.ts:47


spinner

private readonly spinner: Spinner

Source

packages/listr2/src/renderer/default/renderer.ts:48


logger

private readonly logger: ListrLogger<ListrDefaultRendererLogLevels>

Source

packages/listr2/src/renderer/default/renderer.ts:49


updater

private updater: (...text) => void & LogUpdateMethods

Source

packages/listr2/src/renderer/default/renderer.ts:50


truncate

private truncate: (text, columns, options?) => string

Truncate a string to a specific width in the terminal.

Parameters

text: string

The text to truncate.

columns: number

The number of columns to occupy in the terminal.

options?: Options

Returns

string

Example

import cliTruncate from 'cli-truncate';

cliTruncate('unicorn', 4);
//=> 'uni…'

// Truncate at different positions
cliTruncate('unicorn', 4, {position: 'start'});
//=> '…orn'

cliTruncate('unicorn', 4, {position: 'middle'});
//=> 'un…n'

cliTruncate('\u001B[31municorn\u001B[39m', 4);
//=> '\u001B[31muni\u001B[39m…'

// Truncate Unicode surrogate pairs
cliTruncate('uni\uD83C\uDE00corn', 5);
//=> 'uni\uD83C\uDE00…'

// Truncate fullwidth characters
cliTruncate('안녕하세요', 3);
//=> '안…'

// Truncate the paragraph to the terminal width
const paragraph = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa.';
cliTruncate(paragraph, process.stdout.columns);
//=> 'Lorem ipsum dolor sit amet, consectetuer adipiscing…'

Source

packages/listr2/src/renderer/default/renderer.ts:51


wrap

private wrap: (string, columns, options?) => string

Wrap words to the specified column width.

Parameters

string: string

A string with ANSI escape codes, like one styled by chalk. Newline characters will be normalized to \n.

columns: number

The number of columns to wrap the text to.

options?: Options

Returns

string

Example

import chalk from 'chalk';
import wrapAnsi from 'wrap-ansi';

const input = 'The quick brown ' + chalk.red('fox jumped over ') +
	'the lazy ' + chalk.green('dog and then ran away with the unicorn.');

console.log(wrapAnsi(input, 20));

Source

packages/listr2/src/renderer/default/renderer.ts:52


buffer

private readonly buffer: ListrDefaultRendererOutputBuffer

Source

packages/listr2/src/renderer/default/renderer.ts:53


cache

private readonly cache: ListrDefaultRendererCache

Source

packages/listr2/src/renderer/default/renderer.ts:57


tasks

private readonly tasks: ListrDefaultRendererTask[]

Source

packages/listr2/src/renderer/default/renderer.ts:64


options

private readonly options: ListrDefaultRendererOptions

Source

packages/listr2/src/renderer/default/renderer.ts:65


events

private readonly events: ListrEventManager

Source

packages/listr2/src/renderer/default/renderer.ts:66

Methods

render()

render(): Promise<void>

A function to what to do on render

Returns

Promise<void>

Implementation of

ListrRenderer.render

Source

packages/listr2/src/renderer/default/renderer.ts:88


update()

update(): void

Returns

void

Source

packages/listr2/src/renderer/default/renderer.ts:111


end()

end(): void

A function to what to do on end of the render

Returns

void

Implementation of

ListrRenderer.end

Source

packages/listr2/src/renderer/default/renderer.ts:115


create()

create(options?): string

Parameters

options?

options.tasks?: boolean

options.bottomBar?: boolean

options.prompt?: boolean

Returns

string

Source

packages/listr2/src/renderer/default/renderer.ts:130


style()

protected style(task, output): string

Parameters

task: ListrDefaultRendererTask

output: boolean= false

Returns

string

Source

packages/listr2/src/renderer/default/renderer.ts:168


format()

protected format(message, icon, level): string[]

Parameters

message: string

icon: string

level: number

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:216


shouldOutputToOutputBar()

protected shouldOutputToOutputBar(task): boolean

Parameters

task: ListrDefaultRendererTask

Returns

boolean

Source

packages/listr2/src/renderer/default/renderer.ts:257


shouldOutputToBottomBar()

protected shouldOutputToBottomBar(task): boolean

Parameters

task: ListrDefaultRendererTask

Returns

boolean

Source

packages/listr2/src/renderer/default/renderer.ts:263


renderer()

private renderer(tasks, level): string[]

Parameters

tasks: ListrDefaultRendererTask[]

level: number= 0

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:269


renderOutputBar()

private renderOutputBar(task, level): string[]

Parameters

task: ListrDefaultRendererTask

level: number

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:441


renderBottomBar()

private renderBottomBar(): string[]

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:451


renderPrompt()

private renderPrompt(): string[]

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:463


calculate()

private calculate(task): void

Parameters

task: ListrDefaultRendererTask

Returns

void

Source

packages/listr2/src/renderer/default/renderer.ts:471


setupBuffer()

private setupBuffer(task): void

Parameters

task: ListrDefaultRendererTask

Returns

void

Source

packages/listr2/src/renderer/default/renderer.ts:490


reset()

private reset(task): void

Parameters

task: ListrDefaultRendererTask

Returns

void

Source

packages/listr2/src/renderer/default/renderer.ts:534


dump()

private dump(task, level, source, data?): string[]

Parameters

task: ListrDefaultRendererTask

level: number

source: FAILED | SKIPPED | OUTPUT= ListrLogLevels.OUTPUT

data?: string | boolean

Returns

string[]

Source

packages/listr2/src/renderer/default/renderer.ts:542


indent()

private indent(str, i): string

Parameters

str: string

i: number

Returns

string

Source

packages/listr2/src/renderer/default/renderer.ts:579