Skip to content

Conditional Enable

Task can be enabled depending on the variables programmatically. This enables the creation of tasks that are dependent on the context or outside conditions.


Task conditional enable is determined upon the initial run of the Listr when you create the class for a given Task or Subtask, so be careful with using it while using internal context variables.

After the initial evaluation when the execution time comes for that particular Task, it will get re-evaluated.


You can find the related examples here.


import { delay, Listr } from 'listr2'

interface Ctx {
  enableSecondTask?: boolean

const tasks = new Listr<Ctx>(
      title: 'This task will execute.',
      task: (ctx): void => {
        ctx.enableSecondTask = false

      title: 'This task will never execute.',
      enabled: (ctx): boolean => ctx.enableSecondTask,
      task: (): void => {}
  { concurrent: false }



Disabled tasks will not be rendered.