Multiple progress bars with option for indefinite spinners
npm install multi-progress-barsnpm install multi-progress-barsyarn add multi-progress-bars
import { MultiProgressBars } from 'multi-progress-bars';
import * as chalk from 'chalk';
// Initialize mpb
const mpb = new MultiProgressBars({
initMessage: ' $ Example Fullstack Build ',
anchor: 'top',
persist: true,
border: true,
});
// Add tasks
mpb.addTask('Webpack Backend', { type: 'percentage', barColorFn: chalk.yellow });
mpb.addTask('Watcher', { type: 'indefinite', message: 'Watching for changes...' });
// Update tasks
mpb.updateTask('Webpack Backend', { percentage: 0.2 });
mpb.incrementTask('Webpack Backend', { percentage: 0.1 });
// Console logging is overridden and tracked with an interval buffer
console.log('Warning!');
setTimeout(() => { mpb.done('Webpack Backend', { message: 'Build finished.' })}, 5000);
setTimeout(() => { mpb.done('Watcher', { message: 'Build finished.' })}, 1000);
// Wait for all tasks to finish
await mpb.promise;
console.log('Finish');
`
See the Documentation for more information.
Version Changes
> ## :warning: v4 -> v5 has breaking changes.
>* Library now defaults to ESM. Dependencies on chalk and related libraries are now updated to the latest, which default to ESM.
>* For building, node needs to be >14.18 because of Rollup 3
> ## :warning: v3 -> v4 has breaking changes.
> User-Facing Changes:
>* barColorFn is now barTransformFn, and a new property nameTransformFn has been added to transform task names appearance.
>* Number of progress bars displayed will be truncated to terminal height (accounting for borders)
>* Upon exiting, will dump the full untruncated list of progress bars if the above was true.
>* API added for removing tasks, with option to shift up the tasks or leave a blank line.
>* API added for getting the index of a specific task, or getting the name of a task given the index.
>* Extra border options in constructor as well as API to set or remove headers and footers.
>* Bottom-anchored progress bars now has bottom border if border is set to true in the constructor.
> :warning: v2 -> v3 technically has breaking changes in behavior nuance, but should be backwards-compatible. The changes are the addition of anchor position, border, and persist. If you pass in true for persist, you should call mpb.close() when you are done, or on SIGINT` for example. Multi-line init messages are now clamped to the first line.