Skip to content

Commit

Permalink
fix: 🐛 Fix bar width when using ANSI styling (by @jHoldroyd)
Browse files Browse the repository at this point in the history
  • Loading branch information
CPatchane committed Jan 21, 2019
1 parent 35662d8 commit a9b07e9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/cozy-scripts/utils/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,14 @@ ProgressBar.prototype.render = function(tokens, force) {
.replace(':rate', Math.round(rate))

/* compute the available space (non-zero) for the bar */
var clean = str.replace(
// eslint-disable-next-line no-control-regex
/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,
''
)
var availableSpace = Math.max(
0,
this.stream.columns - str.replace(':bar', '').length
this.stream.columns - clean.replace(':bar', '').length
)
if (availableSpace && process.platform === 'win32') {
availableSpace = availableSpace - 1
Expand Down

0 comments on commit a9b07e9

Please sign in to comment.