Skip to content

Documentation / listr2 / ListrTask

Interface: ListrTask<Ctx, Renderer, FallbackRenderer>

Defines the task, conditions and options to run a specific task in the Listr. This defines the external API for the task where TaskWrapper is used internally.

See

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

Extends

Type Parameters

Ctx = ListrContext

Renderer extends ListrRendererFactory = any

FallbackRenderer extends ListrRendererFactory = any

Properties

rendererOptions?

optional rendererOptions: ListrGetRendererTaskOptions<Renderer>

Renderer options depending on the current renderer.

Inherited from

ListrPrimaryRendererTaskOptions.rendererOptions

Defined in

packages/listr2/src/interfaces/renderer.interface.ts:102


fallbackRendererOptions?

optional fallbackRendererOptions: ListrGetRendererTaskOptions<FallbackRenderer>

Renderer options depending on the fallback renderer.

Inherited from

ListrSecondaryRendererTaskOptions.fallbackRendererOptions

Defined in

packages/listr2/src/interfaces/renderer.interface.ts:120


title?

optional title: string | any[]

Title of the task.

Give this task a title to enchance it on the preferred renderer.

  • Tasks without a title will be hidden from view in renderers and will act as a background task.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:26


task

task: ListrTaskFn<Ctx, Renderer, FallbackRenderer>

The task itself in the form of a Function, Promise, Listr, Observable or Stream.

  • Task will be executed, whenever the provided criterion is met with the current state and whenever the time for that specific task has come.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:34


enabled?

optional enabled: boolean | (ctx) => boolean | Promise<boolean>

Enable a task depending on the context.

  • The callback function will be evaluated before all the tasks start to check which tasks has been enabled.
  • The callback function will be evaluated again before the task starts.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:43


skip?

optional skip: string | boolean | (ctx) => string | boolean | Promise<string | boolean>

Skip this task depending on the context.

  • The callback function will be evaluated once before the task starts.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:51


retry?

optional retry: number | object

Retries a task with the given amounts whenever a task fails.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:57


rollback?

optional rollback: ListrTaskFn<Ctx, Renderer, FallbackRenderer>

The callback function that you provide will run whenever the attached task fails and give you the ability to revert your changes, before failing.

See

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

Defined in

packages/listr2/src/interfaces/task.interface.ts:64


exitOnError?

optional exitOnError: boolean | (ctx) => boolean | Promise<boolean>

Determine the default behavior of exiting on errors for this attached task.

Defined in

packages/listr2/src/interfaces/task.interface.ts:68