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()

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

Parameters

task: ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Returns

ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>

Defined in

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

Properties

task

task: ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Defined in

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

Accessors

title

Get Signature

get title(): string

Returns

string

Set Signature

set title(title): void

Title of the current task.

See

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

Parameters

title: string | any[]

Returns

void

Defined in

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


output

Get Signature

get output(): string

Returns

string

Set Signature

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

void

Defined in

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

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

Defined in

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

Defined in

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

Defined in

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

Defined in

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

Defined in

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

Defined in

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


run()

run(ctx): Promise<void>

Run this task.

Parameters

ctx: Ctx

Returns

Promise<void>

Defined in

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