How to use the supports-color.stdout.has16m function in supports-color

To help you get started, we’ve selected a few supports-color 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 DefinitelyTyped / DefinitelyTyped / types / supports-color / supports-color-tests.ts View on Github external
import { stdout, stderr } from "supports-color";

if (stdout) {
    // Terminal standard output supports color
}

if (stdout.hasBasic) {
    // Terminal standard output supports color
}

if (stdout.has256) {
    // Terminal standard output supports 256 colors
}

if (stdout.has16m) {
    // Terminal standard output supports 16 million colors (truecolor)
}

if (stderr) {
    // Terminal standard error supports color
}

if (stderr.hasBasic) {
    // Terminal standard error supports color
}

if (stderr.has256) {
    // Terminal standard error supports 256 colors
}

if (stderr.has16m) {
github BlackB1RD-Development / tools-kit / src / util.js View on Github external
const colors = {
  black: stdout.has16m ? '\u001B[38;2;0;0;0m' : '\u001B[30m',
  gray: stdout.has16m ? '\u001B[38;2;128;128;128m' : '\u001B[90m',
  grey: stdout.has16m ? '\u001B[38;2;128;128;128m' : '\u001B[90m',
  red: stdout.has16m ? '\u001B[38;2;255;0;0m' : '\u001B[31m',
  green: stdout.has16m ? '\u001B[38;2;0;255;0m' : '\u001B[32m',
  yellow: stdout.has16m ? '\u001B[38;2;255;255;0m' : '\u001B[33m',
  blue: stdout.has16m ? '\u001B[38;2;0;0;255m' : '\u001B[34m',
  magenta: stdout.has16m ? '\u001B[38;2;255;0;255m' : '\u001B[35m',
  cyan: stdout.has16m ? '\u001B[38;2;0;255;255m' : '\u001B[36m',
  white: stdout.has16m ? '\u001B[38;2;255;255;255m' : '\u001B[37m',

  lblack: '\u001B[30m',
  lred: stdout.has16m ? '\u001B[38;2;255;85;85m' : '\u001B[31m',
  lgreen: stdout.has16m ? '\u001B[38;2;85;255;85m' : '\u001B[32m',
  lyellow: stdout.has16m ? '\u001B[38;2;255;255;85m' : '\u001B[33m',
  lblue: stdout.has16m ? '\u001B[38;2;85;85;255m' : '\u001B[34m',
  lmagenta: stdout.has16m ? '\u001B[38;2;255;85;255m' : '\u001B[35m',
  lcyan: stdout.has16m ? '\u001B[38;2;85;255;255m' : '\u001B[36m',
  lwhite: stdout.has16m ? '\u001B[38;2;255;255;255m' : '\u001B[37m',

  bgray: '\u001B[90m',
  bgrey: '\u001B[90m',
  bred: stdout.has16m ? '\u001B[38;2;255;0;0m' : '\u001B[91m',
  bgreen: stdout.has16m ? '\u001B[38;2;0;255;0m' : '\u001B[92m',
  byellow: stdout.has16m ? '\u001B[38;2;255;255;0m' : '\u001B[93m',
  bblue: stdout.has16m ? '\u001B[38;2;0;0;255m' : '\u001B[94m',
  bmagenta: stdout.has16m ? '\u001B[38;2;255;0;255m' : '\u001B[95m',
  bcyan: stdout.has16m ? '\u001B[38;2;0;255;255m' : '\u001B[96m',
  bwhite: stdout.has16m ? '\u001B[38;2;255;255;255m' : '\u001B[97m'
};