How to use supports-color - 10 common examples

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 flow-typed / flow-typed / definitions / npm / supports-color_v3.x.x / test_supports-color_v3.x.x.js View on Github external
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 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 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 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
github flow-typed / flow-typed / definitions / npm / supports-color_v3.x.x / test_supports-color_v3.x.x.js View on Github external
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 alan-ai / alan-sdk-reactnative / testtools / node_modules / @expo / config / node_modules / chalk / source / index.js View on Github external
const applyOptions = (object, options = {}) => {
	if (options.level > 3 || options.level < 0) {
		throw new Error('The `level` option should be an integer from 0 to 3');
	}

	// Detect level if not set manually
	const colorLevel = stdoutColor ? stdoutColor.level : 0;
	object.level = options.level === undefined ? colorLevel : options.level;
};
github alan-ai / alan-sdk-reactnative / testtools / node_modules / @expo / config / node_modules / chalk / source / index.js View on Github external
String(firstString.raw[i])
		);
	}

	if (template === undefined) {
		template = require('./templates');
	}

	return template(chalk, parts.join(''));
};

Object.defineProperties(Chalk.prototype, styles);

const chalk = Chalk(); // eslint-disable-line new-cap
chalk.supportsColor = stdoutColor;
chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap
chalk.stderr.supportsColor = stderrColor;

// For TypeScript
chalk.Level = {
	None: 0,
	Basic: 1,
	Ansi256: 2,
	TrueColor: 3,
	0: 'None',
	1: 'Basic',
	2: 'Ansi256',
	3: 'TrueColor'
};

module.exports = chalk;
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 DefinitelyTyped / DefinitelyTyped / types / supports-color / supports-color-tests.ts View on Github external
// 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) {
    // Terminal standard error supports 16 million colors (truecolor)
}