ts
import { delay, Listr } from 'listr2'
const tasks = new Listr(
[
{
title: 'This task will execute.',
task: (ctx, task): Listr =>
task.newListr(
[
{
title: 'This is a subtask.',
task: async(): Promise<void> => {
await delay(3000)
}
},
{
title: 'This is an another subtask.',
task: async(): Promise<void> => {
await delay(2000)
}
}
],
{ concurrent: true, rendererOptions: { collapseSubtasks: true } }
)
},
{
title: 'This task will execute.',
task: (ctx, task): Listr =>
task.newListr(
[
{
title: 'This is a subtask.',
task: async(): Promise<void> => {
await delay(3000)
}
},
{
title: 'This is an another subtask.',
task: async(): Promise<void> => {
await delay(2000)
}
}
],
{ concurrent: false, rendererOptions: { collapseSubtasks: false } }
)
}
],
{ concurrent: false }
)
const ctx = await tasks.run()
Code Example
Example
You can find the related examples here.