How to use the @boost/terminal.style.red function in @boost/terminal

To help you get started, we’ve selected a few @boost/terminal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github milesj / boost / packages / core / src / outputs / ProgressOutput.ts View on Github external
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);
  }
}