How to use the supports-color.has256 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 flow-typed / flow-typed / definitions / npm / supports-color_v3.x.x / test_supports-color_v3.x.x.js View on Github external
import supportsColor from 'supports-color';

if (supportsColor) {
  console.log('Terminal supports color');

  if (supportsColor.hasBasic) {
    const level: number = supportsColor.level;
    console.log('Terminal has basic color support', level);
  }

  if (supportsColor.has256) {
    console.log('Terminal supports 256 colors');
  }

  if (supportsColor.has16m) {
    console.log('Terminal supports 16 million colors (truecolor)');
  }

  // $ExpectError
  supportsColor.nope;

  // $ExpectError
  (supportsColor.level: string);
}
github inspire-software / yes-cart / manager / jam-jsclient / src / main / typescript / tools / tasks / seed / print.banner.ts View on Github external
export = (done: any) => {
  let bannerPath = join(Config.TOOLS_DIR, 'config', 'ycbanner.txt'); // #YC#
  if (require('supports-color').has256) {
    bannerPath = join(Config.TOOLS_DIR, 'config', 'ycbanner-256.txt'); // #YC#
  }
  readFile(bannerPath, (e, content) => {
    if (!e) {
      console.log(util.colors.blue(content.toString()));
    }
    done();
  });
};
github bradyhouse / house / fiddles / angular2-seeder / fiddle-0000-Template / tools / tasks / seed / print.banner.ts View on Github external
export = (done: any) => {
  let bannerPath = join(Config.TOOLS_DIR, 'config', 'banner.txt');
  const colors = require('supports-color');
  if (colors.has256 || colors.stdout.has256) {
    bannerPath = join(Config.TOOLS_DIR, 'config', 'banner-256.txt');
  }
  readFile(bannerPath, (e, content) => {
    if (!e) {
      console.log(util.colors.green(content.toString()));
    }
    done();
  });
};
github heroku / heroku-cli-util / lib / color.js View on Github external
colors.heroku = s => {
  if (!chalk.enabled) return s
  let supports = require('supports-color')
  if (!supports) return s
  supports.has256 = supports.has256 || (process.env.TERM || '').indexOf('256') !== -1
  return supports.has256 ? '\u001b[38;5;104m' + s + styles.reset.open : chalk.magenta(s)
}