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

Source

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


fallbackRendererOptions?

optional fallbackRendererOptions: ListrGetRendererTaskOptions<FallbackRenderer>

Renderer options depending on the fallback renderer.

Inherited from

ListrSecondaryRendererTaskOptions.fallbackRendererOptions

Source

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

Source

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


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

Source

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


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

Source

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


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

Source

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


retry?

optional retry: number | Object

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

See

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

Source

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


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

Source

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


exitOnError?

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

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

Source

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