Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const currentWidth = partialTemplate.replace('{bar}', '').length;
const remainingWidth = screen.size().columns - currentWidth;
const completed = Math.round(remainingWidth * progress);
const [complete, incomplete] = STYLES[styleName];
let bar = [
complete.repeat(Math.max(0, completed)),
(transparent ? ' ' : incomplete).repeat(Math.max(0, remainingWidth - completed)),
].join('');
if (color) {
if (percent >= 90) {
bar = style.green(bar);
} else if (percent >= 45) {
bar = style.yellow(bar);
} else {
bar = style.red(bar);
}
}
return partialTemplate.replace('{bar}', bar);
}
}