Skip to content

Commit

Permalink
added colors dependency to snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Nov 20, 2021
1 parent 0457e84 commit 5cc4f39
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ Single Bar Mode

```js
const cliProgress = require('cli-progress');
const colors = require('colors');

// create new progress bar
const b1 = new cliProgress.SingleBar({
format: 'CLI Progress |' + _colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}',
format: 'CLI Progress |' + colors.cyan('{bar}') + '| {percentage}% || {value}/{total} Chunks || Speed: {speed}',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591',
hideCursor: true
Expand Down Expand Up @@ -302,9 +303,9 @@ function formatter(options, params, payload){
// end value reached ?
// change color to green when finished
if (params.value >= params.total){
return '# ' + _colors.grey(payload.task) + ' ' + _colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
return '# ' + colors.grey(payload.task) + ' ' + colors.green(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
}else{
return '# ' + payload.task + ' ' + _colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
return '# ' + payload.task + ' ' + colors.yellow(params.value + '/' + params.total) + ' --[' + bar + ']-- ';
}
}

Expand Down Expand Up @@ -393,10 +394,10 @@ bar.stop();
**File** `myPreset.js`

```js
const _colors = require('colors');
const colors = require('colors');

module.exports = {
format: _colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
format: colors.red(' {bar}') + ' {percentage}% | ETA: {eta}s | {value}/{total} | Speed: {speed} kbit',
barCompleteChar: '\u2588',
barIncompleteChar: '\u2591'
};
Expand Down

0 comments on commit 5cc4f39

Please sign in to comment.