Skip to content

Documentation / listr2 / ListrTaskWrapper

Class: ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>

The original Task that is defined by the user is wrapped with the TaskWrapper to provide additional functionality.

See

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

Type parameters

Ctx

Renderer extends ListrRendererFactory

FallbackRenderer extends ListrRendererFactory

Constructors

new ListrTaskWrapper(task)

new ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>(task): ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>

Parameters

task: ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Returns

ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>

Source

packages/listr2/src/lib/task-wrapper.ts:16

Properties

task

task: ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Source

packages/listr2/src/lib/task-wrapper.ts:16

Accessors

title

get title(): string

set title(title): void

Title of the current task.

See

https://listr2.kilic.dev/task/title.html

Parameters

title: string | any[]

Returns

string

Source

packages/listr2/src/lib/task-wrapper.ts:19


output

get output(): string

set output(output): void

Send output from the current task to the renderer.

See

https://listr2.kilic.dev/task/output.html

Parameters

output: string | any[]

Returns

string

Source

packages/listr2/src/lib/task-wrapper.ts:35


promptOutput

set private promptOutput(output): void

Send an output to the output channel as prompt.

Parameters

output: string

Source

packages/listr2/src/lib/task-wrapper.ts:53

Methods

newListr()

newListr<NewCtx>(task, options?): Listr<NewCtx, any, any>

Creates a new set of Listr subtasks.

Type parameters

NewCtx = Ctx

Parameters

task: ListrTask<NewCtx, Renderer, FallbackRenderer> | ListrTask<NewCtx, Renderer, FallbackRenderer>[] | (parent) => ListrTask<NewCtx, Renderer, FallbackRenderer> | ListrTask<NewCtx, Renderer, FallbackRenderer>[]

options?: ListrSubClassOptions<NewCtx, Renderer, FallbackRenderer>

Returns

Listr<NewCtx, any, any>

See

https://listr2.kilic.dev/task/subtasks.html

Source

packages/listr2/src/lib/task-wrapper.ts:62


report()

report(error, type): void

Report an error that has to be collected and handled.

Parameters

error: Error

type: ListrErrorTypes

Returns

void

See

https://listr2.kilic.dev/task/error-handling.html

Source

packages/listr2/src/lib/task-wrapper.ts:85


skip()

skip(message?, ...metadata?): void

Skip the current task.

Parameters

message?: string

• ...metadata?: any[]

Returns

void

See

https://listr2.kilic.dev/task/skip.html

Source

packages/listr2/src/lib/task-wrapper.ts:98


isRetrying()

isRetrying(): ListrTaskRetry

Check whether this task is currently in a retry state.

Returns

ListrTaskRetry

See

https://listr2.kilic.dev/task/retry.html

Source

packages/listr2/src/lib/task-wrapper.ts:111


prompt()

prompt<T>(adapter): T

Create a new prompt for getting user input through the prompt adapter. This will create a new prompt through the adapter if the task is not currently rendering a prompt or will return the active instance.

This part of the application requires optional peer dependencies, please refer to documentation.

Type parameters

T extends ListrPromptAdapter = ListrPromptAdapter

Parameters

adapter

Returns

T

See

https://listr2.kilic.dev/task/prompt.html

Source

packages/listr2/src/lib/task-wrapper.ts:124


stdout()

stdout(type?): WritableStream

Generates a fake stdout for your use case, where it will be tunnelled through Listr to handle the rendering process.

Parameters

type?: PROMPT | OUTPUT

Returns

WritableStream

See

https://listr2.kilic.dev/renderer/process-output.html

Source

packages/listr2/src/lib/task-wrapper.ts:140


run()

run(ctx): Promise<void>

Run this task.

Parameters

ctx: Ctx

Returns

Promise<void>

Source

packages/listr2/src/lib/task-wrapper.ts:155