Creating a New Instance

Generate New Class

Create a new task list from the constructor. It will return a Listr class.

import { Listr } from 'listr2'

interface Ctx {
  /* some variables for internal use */
}

const tasks = new Listr<Ctx>(
  [
    /* tasks */
  ],
  {
    /* options */
  }
)

Run the Generated Task List

Then you can run this task list as an async function and it will return the context that is used.

try {
  await tasks.run()
} catch (e) {
  console.error(e)
}
Edit this page on GitHub Updated at Tue, Feb 1, 2022