Listr renderer with simple tree support (non concurrent tasks)
npm install listr-simple-tree-renderer> Listr simple tree renderer
* Shows simple task list in non-concurrent mode to support long task list (with visible subtask list).
* Inspired by listr-verbose-renderer and listr-update-renderer
* Task spinners are not used to allow rendering tree with history.
* Why this package when we can use listr-update-renderer?
```
$ npm install --save listr-simple-tree-renderer
`js
const SimpleTreeRenderer = require('listr-simple-tree-renderer');
const Listr = require('listr');
const list = new Listr([
{
title: 'foo',
task: () => Promise.resolve('bar')
},
{
title: 'Output can be function to change text',
task: (context, task) => {
task.output = () => {
return ${figures.tick} Custom render
}
}
}
], {
renderer: SimpleTreeRenderer
});
list.run();
`
These options should be provided in the Listr options object.
Type: booleantrue
Default:
Append every indention based on corresponding level task.
Type: stringpointer
Default:
Icon that will be displayed next to the task name. Icon list in figures package
Need to show spinner? Use custom rendering which will clear the output before changing task.
`js
const logUpdate = require('log-update')
const ElegantSpinner = require('elegant-spinner')
/**
* Shows spinner and runs given task. Returns value from the promise task.
*
* Do not output any data within promise task.
*
* @param {string} title
* @param {Function} promiseTask
* @return {Promise
*/
module.exports = async function (title, promiseTask) {
function cancel () {
clearInterval(interval)
logUpdate.clear()
}
const spinner = ElegantSpinner()
// Show the spinner
const interval = setInterval(() => {
logUpdate(spinner() + ' ' + title)
}, 100)
try {
const response = await promiseTask()
cancel()
return response
} catch (e) {
cancel()
throw e
}
}
task = {
title: 'test',
task: (context, task) => showSpinner('Loading', async () => {
return await somethingThatWillReturnTitle()
}).then((title) => {
task.output = title
})
}
``
- listr - Terminal task list
- listr-update-renderer - Listr update renderer
- listr-silent-renderer - Suppress Listr rendering output
MIT © Martin Kluska