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

Source

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

Properties

id

id: string

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

Source

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


state

state: ListrTaskState = ListrTaskState.WAITING

The current state of the task.

Source

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


subtasks

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

Subtasks of the current task.

Source

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


title?

optional title: string

Title of the task.

Source

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


initialTitle?

optional readonly initialTitle: string

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

Source

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


output?

optional output: string

Output channel for the task.

Source

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


retry?

optional retry: ListrTaskRetry

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

Source

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.

Source

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


prompt

prompt: ListrPromptAdapter

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

Source

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


parent?

optional parent: ListrTaskObject<Ctx, any, any>

Parent task of the current task.

Source

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


enabled

private enabled: boolean

Enable flag of this task.

Source

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


taskFn

private taskFn: ListrTaskFn<Ctx, Renderer, FallbackRenderer>

User provided Task callback function to run.

Source

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


closed

private closed: boolean

Marks the task as closed. This is different from finalized since this is not really related to task itself.

Source

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


listr

listr: Listr<Ctx, Renderer, FallbackRenderer>

Source

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


task

task: ListrTask<Ctx, Renderer, FallbackRenderer>

Source

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


options

options: ListrOptions<any>

Source

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


rendererOptions

rendererOptions: ListrGetRendererOptions<FallbackRenderer> | ListrGetRendererOptions<Renderer>

Source

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


rendererTaskOptions

rendererTaskOptions: ListrGetRendererTaskOptions<FallbackRenderer> | ListrGetRendererTaskOptions<Renderer>

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

Source

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

Accessors

state$

set state$(state): void

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

Parameters

state: ListrTaskState

Source

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


output$

set output$(data): void

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

Parameters

data: string

Source

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


promptOutput$

set promptOutput$(data): void

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

Parameters

data: string

Source

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


message$

set message$(data): void

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

Parameters

data: ListrTaskMessage

Source

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


title$

set title$(title): void

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

Parameters

title: string

Source

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


path

get path(): string[]

Current task path in the hierarchy.

Returns

string[]

Source

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

Source

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

Source

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

Source

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

Source

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


complete()

complete(): void

Returns

void

Inherited from

ListrTaskEventManager.complete

Source

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>

Source

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


hasSubtasks()

hasSubtasks(): boolean

Returns whether this task has subtasks.

Returns

boolean

Source

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


hasFinalized()

hasFinalized(): boolean

Returns whether this task is finalized in someform.

Returns

boolean

Source

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


isPending()

isPending(): boolean

Returns whether this task is in progress.

Returns

boolean

Source

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


isStarted()

isStarted(): boolean

Returns whether this task has started.

Returns

boolean

Source

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


isSkipped()

isSkipped(): boolean

Returns whether this task is skipped.

Returns

boolean

Source

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


isCompleted()

isCompleted(): boolean

Returns whether this task has been completed.

Returns

boolean

Source

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


hasFailed()

hasFailed(): boolean

Returns whether this task has been failed.

Returns

boolean

Source

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


isRollingBack()

isRollingBack(): boolean

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

Returns

boolean

Source

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


hasRolledBack()

hasRolledBack(): boolean

Returns whether the rollback action was successful.

Returns

boolean

Source

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


isRetrying()

isRetrying(): boolean

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

Returns

boolean

Source

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

Source

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


isEnabled()

isEnabled(): boolean

Returns whether enabled function resolves to true.

Returns

boolean

Source

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


hasTitle()

hasTitle(): boolean

Returns whether this task actually has a title.

Returns

boolean

Source

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


isPrompt()

isPrompt(): boolean

Returns whether this task has a prompt inside.

Returns

boolean

Source

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


isPaused()

isPaused(): boolean

Returns whether this task is currently paused.

Returns

boolean

Source

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


isClosed()

isClosed(): boolean

Returns whether this task is closed.

Returns

boolean

Source

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>

Source

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>

Source

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


close()

private close(): void

Returns

void

Source

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