Skip to content

Documentation / listr2 / ListrTaskObject

Class: ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Creates and handles a runnable instance of the Task.

Extends

Type Parameters

Ctx

Renderer extends ListrRendererFactory = ListrRendererFactory

FallbackRenderer extends ListrRendererFactory = ListrRendererFactory

Constructors

new ListrTaskObject()

new ListrTaskObject<Ctx, Renderer, FallbackRenderer>(listr, task, options, rendererOptions, rendererTaskOptions): ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Parameters

listr: Listr<Ctx, Renderer, FallbackRenderer>

task: ListrTask<Ctx, Renderer, FallbackRenderer>

options: ListrOptions<any>

rendererOptions: ListrGetRendererOptions<Renderer> | ListrGetRendererOptions<FallbackRenderer>

rendererTaskOptions: ListrGetRendererTaskOptions<Renderer> | ListrGetRendererTaskOptions<FallbackRenderer>

Per-task options for the current renderer of the task.

Returns

ListrTaskObject<Ctx, Renderer, FallbackRenderer>

Overrides

ListrTaskEventManager.constructor

Defined in

packages/listr2/src/lib/task.ts:61

Properties

id

id: string

Unique id per task, can be used for identifying a Task.

Defined in

packages/listr2/src/lib/task.ts:30


state

state: ListrTaskState = ListrTaskState.WAITING

The current state of the task.

Defined in

packages/listr2/src/lib/task.ts:32


subtasks

subtasks: ListrTaskObject<Ctx, Renderer, FallbackRenderer>[]

Subtasks of the current task.

Defined in

packages/listr2/src/lib/task.ts:34


title?

optional title: string

Title of the task.

Defined in

packages/listr2/src/lib/task.ts:36


initialTitle?

readonly optional initialTitle: string

Initial/Untouched version of the title for using whenever task has a reset.

Defined in

packages/listr2/src/lib/task.ts:38


output?

optional output: string

Output channel for the task.

Defined in

packages/listr2/src/lib/task.ts:40


retry?

optional retry: ListrTaskRetry

Current state of the retry process whenever the task is retrying.

Defined in

packages/listr2/src/lib/task.ts:42


message

message: ListrTaskMessage = {}

A channel for messages.

This requires a separate channel for messages like error, skip or runtime messages to further utilize in the renderers.

Defined in

packages/listr2/src/lib/task.ts:48


prompt

prompt: ListrPromptAdapter

Current prompt instance or prompt error whenever the task is prompting.

Defined in

packages/listr2/src/lib/task.ts:50


parent?

optional parent: ListrTaskObject<Ctx, any, any>

Parent task of the current task.

Defined in

packages/listr2/src/lib/task.ts:52


listr

listr: Listr<Ctx, Renderer, FallbackRenderer>

Defined in

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


task

task: ListrTask<Ctx, Renderer, FallbackRenderer>

Defined in

packages/listr2/src/lib/task.ts:63


options

options: ListrOptions<any>

Defined in

packages/listr2/src/lib/task.ts:64


rendererOptions

rendererOptions: ListrGetRendererOptions<FallbackRenderer> | ListrGetRendererOptions<Renderer>

Defined in

packages/listr2/src/lib/task.ts:65


rendererTaskOptions

rendererTaskOptions: ListrGetRendererTaskOptions<FallbackRenderer> | ListrGetRendererTaskOptions<Renderer>

Per-task options for the current renderer of the task.

Defined in

packages/listr2/src/lib/task.ts:67

Accessors

state$

Set Signature

set state$(state): void

Update the current state of the Task and emit the neccassary events.

Parameters

state: ListrTaskState

Returns

void

Defined in

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


output$

Set Signature

set output$(data): void

Update the current output of the Task and emit the neccassary events.

Parameters

data: string

Returns

void

Defined in

packages/listr2/src/lib/task.ts:105


promptOutput$

Set Signature

set promptOutput$(data): void

Update the current prompt output of the Task and emit the neccassary events.

Parameters

data: string

Returns

void

Defined in

packages/listr2/src/lib/task.ts:115


message$

Set Signature

set message$(data): void

Update or extend the current message of the Task and emit the neccassary events.

Parameters

data: ListrTaskMessage

Returns

void

Defined in

packages/listr2/src/lib/task.ts:128


title$

Set Signature

set title$(title): void

Update the current title of the Task and emit the neccassary events.

Parameters

title: string

Returns

void

Defined in

packages/listr2/src/lib/task.ts:138


path

Get Signature

get path(): string[]

Current task path in the hierarchy.

Returns

string[]

Defined in

packages/listr2/src/lib/task.ts:148

Methods

emit()

emit<E>(dispatch, args?): void

Type Parameters

E extends ListrTaskEventType = ListrTaskEventType

Parameters

dispatch: E

args?: EventData<E, ListrTaskEventMap>

Returns

void

Inherited from

ListrTaskEventManager.emit

Defined in

packages/listr2/src/lib/event-manager.ts:8


on()

on<E>(dispatch, handler): void

Type Parameters

E extends ListrTaskEventType = ListrTaskEventType

Parameters

dispatch: E

handler

Returns

void

Inherited from

ListrTaskEventManager.on

Defined in

packages/listr2/src/lib/event-manager.ts:12


once()

once<E>(dispatch, handler): void

Type Parameters

E extends ListrTaskEventType = ListrTaskEventType

Parameters

dispatch: E

handler

Returns

void

Inherited from

ListrTaskEventManager.once

Defined in

packages/listr2/src/lib/event-manager.ts:16


off()

off<E>(dispatch, handler?): void

Type Parameters

E extends ListrTaskEventType = ListrTaskEventType

Parameters

dispatch: E

handler?

Returns

void

Inherited from

ListrTaskEventManager.off

Defined in

packages/listr2/src/lib/event-manager.ts:20


complete()

complete(): void

Returns

void

Inherited from

ListrTaskEventManager.complete

Defined in

packages/listr2/src/lib/event-manager.ts:24


check()

check(ctx): Promise<boolean>

Checks whether the current task with the given context should be set as enabled.

Parameters

ctx: Ctx

Returns

Promise<boolean>

Defined in

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


hasSubtasks()

hasSubtasks(): boolean

Returns whether this task has subtasks.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:168


hasFinalized()

hasFinalized(): boolean

Returns whether this task is finalized in someform.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:173


isPending()

isPending(): boolean

Returns whether this task is in progress.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:178


isStarted()

isStarted(): boolean

Returns whether this task has started.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:183


isSkipped()

isSkipped(): boolean

Returns whether this task is skipped.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:188


isCompleted()

isCompleted(): boolean

Returns whether this task has been completed.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:193


hasFailed()

hasFailed(): boolean

Returns whether this task has been failed.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:198


isRollingBack()

isRollingBack(): boolean

Returns whether this task has an active rollback task going on.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:203


hasRolledBack()

hasRolledBack(): boolean

Returns whether the rollback action was successful.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:208


isRetrying()

isRetrying(): boolean

Returns whether this task has an actively retrying task going on.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:213


hasReset()

hasReset(): boolean

Returns whether this task has some kind of reset like retry and rollback going on.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:218


isEnabled()

isEnabled(): boolean

Returns whether enabled function resolves to true.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:223


hasTitle()

hasTitle(): boolean

Returns whether this task actually has a title.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:228


isPrompt()

isPrompt(): boolean

Returns whether this task has a prompt inside.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:233


isPaused()

isPaused(): boolean

Returns whether this task is currently paused.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:238


isClosed()

isClosed(): boolean

Returns whether this task is closed.

Returns

boolean

Defined in

packages/listr2/src/lib/task.ts:243


pause()

pause(time): Promise<void>

Pause the given task for certain time.

Parameters

time: number

Returns

Promise<void>

Defined in

packages/listr2/src/lib/task.ts:248


run()

run(context, wrapper): Promise<void>

Run the current task.

Parameters

context: Ctx

wrapper: ListrTaskWrapper<Ctx, Renderer, FallbackRenderer>

Returns

Promise<void>

Defined in

packages/listr2/src/lib/task.ts:263