How to use ansi-align - 4 common examples

To help you get started, we’ve selected a few ansi-align 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 flocasts / flagpole / dist / cli / cli-helper.js View on Github external
function printSubheader(heading) {
    if (!__1.Flagpole.quietMode) {
        console.log(ansiAlign.center("\x1b[31m===========================================================================\n" +
            "\x1b[0m" + heading + "\n" +
            "\x1b[31m===========================================================================\x1b[0m\n"));
    }
}
exports.printSubheader = printSubheader;
github flocasts / flagpole / src / cli / cli-helper.ts View on Github external
export function printSubheader(heading: string) {
  if (!FlagpoleExecution.opts.quietMode) {
    console.log(
      ansiAlign.center(
        "\x1b[31m===========================================================================\x1b[0m\n" +
          "\x1b[0m" +
          heading +
          "\n" +
          "\x1b[31m===========================================================================\x1b[0m\n"
      )
    );
  }
}
github MarcusCemes / responsive-image-builder / src / Utility.ts View on Github external
export function centreText(text: string, width: number): string {
  const wrappedLine: string = ansiAlign.center(wrapAnsi(text, width) + "\n" + " ".repeat(width));
  return wrappedLine.substring(0, wrappedLine.lastIndexOf("\n"));
}
github EvanBacon / react-native-ink / src / exports / Text / index.ts View on Github external
function withStyle({ children, style }: any): string {
  const flattenStyle = StyleSheetflattenStyle(style) || {};
  const textAlign = flattenStyle.textAlign || 'left';
  const alignSelf = flattenStyle.alignSelf || 'flex-start';
  const hasBorders = styleHasBorders(flattenStyle);
  const borderColors = hasBorders && borderColorFromStyle(style);

  const backgroundColor = flattenStyle.backgroundColor
    ? normalizeColor(flattenStyle.backgroundColor)
    : null;
  const borderStyle = hasBorders && resolveBorderStyle(flattenStyle);
  children = ansiAlign(children, { align: textAlign });
  children = colorizeText(children, flattenStyle);

  if (asArray(flattenStyle.fontWeight).includes('bold')) {
    children = chalk.bold(children);
  }

  if (['italic', 'oblique'].includes(flattenStyle.fontStyle)) {
    children = chalk.italic(children);
  }

  const _textDecorationStyle = asArray(flattenStyle.textDecorationStyle);
  if (_textDecorationStyle.includes('underline')) {
    children = chalk.underline(children);
  }
  if (_textDecorationStyle.includes('line-through')) {
    children = chalk.strikethrough(children);

ansi-align

align-text with ANSI support for CLIs

ISC
Latest version published 3 years ago

Package Health Score

65 / 100
Full package analysis

Popular ansi-align functions