Documentation
    Preparing search index...

    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.

    interface ListrTask<
        Ctx = ListrContext,
        Renderer extends ListrRendererFactory = any,
        FallbackRenderer extends ListrRendererFactory = any,
    > {
        enabled?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
        exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>);
        fallbackRendererOptions?: ListrGetRendererTaskOptions<FallbackRenderer>;
        rendererOptions?: ListrGetRendererTaskOptions<Renderer>;
        retry?: number | { delay?: number; tries: number };
        rollback?: ListrTaskFn<Ctx, Renderer, FallbackRenderer>;
        skip?:
            | string
            | boolean
            | ((ctx: Ctx) => string | boolean | Promise<string | boolean>);
        task: ListrTaskFn<Ctx, Renderer, FallbackRenderer>;
        title?: string | any[];
    }

    Type Parameters

    • Ctx = ListrContext
    • Renderer extends ListrRendererFactory = any
    • FallbackRenderer extends ListrRendererFactory = any

    Hierarchy

    Index

    Properties

    enabled?: boolean | ((ctx: 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.
    exitOnError?: boolean | ((ctx: Ctx) => boolean | Promise<boolean>)

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

    fallbackRendererOptions?: ListrGetRendererTaskOptions<FallbackRenderer>

    Renderer options depending on the fallback renderer.

    rendererOptions?: ListrGetRendererTaskOptions<Renderer>

    Renderer options depending on the current renderer.

    retry?: number | { delay?: number; tries: number }

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

    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.

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

    Skip this task depending on the context.

    • The callback function will be evaluated once before the task starts.
    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.
    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.