Enabling a Task
Introduction
Tasks can be enabled depending on the variables programmatically. This enables to create of tasks that are dependent on the context.
Task enabling is determined upon the initial run of the Listr when you actually create the class for a given subtask, so be careful with using it while using internal context variables.
After that when the execution time comes for the given task, it will get re-evaluated.
Usage
Please refer to examples section for more detailed and further examples.
new Listr<Ctx>(
[
{
title: 'This task will execute.',
task: (ctx): void => {
ctx.skip = true
}
},
{
title: 'This task will never execute.',
enabled: (ctx): boolean => !ctx.skip,
task: (): void => {}
}
],
{ concurrent: false }
)
Renderer
Default Renderer
- Not enabled tasks will not be renderer in the default renderer.