UNPKG

liveperson-functions-cli

Version:
59 lines 1.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TaskList = void 0; const Listr = require("listr"); /** * {@link https://github.com/SamVerschueren/listr} * @export * @class TaskList */ class TaskList { constructor(options = {}) { this.tasks = []; this.options = options; } /** * Add a task to the tasklist * @param {Listr.ListrTask} task - task * @returns {TaskList} - Instance of tasklist * @memberof TaskList */ addTask(task) { this.tasks.push(task); return this; } /** * Adds a nested tasklist * @param {INestedTaskList} { title, tasks, options } - nested task * @returns {TaskList} - instance of tasklist * @memberof TaskList */ addNestedTaskList({ title, tasks, options, }) { /* istanbul ignore next */ const nestedTaskList = () => new Listr(tasks, options); this.tasks.push({ title, task: nestedTaskList, }); return this; } /** * Returns all added tasks * @returns {Listr.ListrTask[]} - tasks * @memberof TaskList */ getTasks() { return this.tasks; } /** * Runs the tasklist * @param { context } - Listr specific context * @returns {Promise<void>} * @memberof TaskList */ async run({ context, taskList = new Listr(this.tasks, this.options), } = {}) { await taskList.run(context); } } exports.TaskList = TaskList; //# sourceMappingURL=tasklist.js.map