How to use the supports-color.level 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 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 medikoo / log / env / node.js View on Github external
// Resolve from LOG4_* env vars
logger.predefinedLevels.forEach(function (level) {
	var varName = "LOG_" + level.toUpperCase();
	if (process.env[varName]) conf[level] = process.env[varName].split(",");
});
// Eventually support as fallback DEBUG env var
if (!conf.debug && process.env.DEBUG) conf.debug = process.env.DEBUG.split(",");
// Do not show debug level logs by default
if (!conf.debug) conf.debug = [];
conf.debug.unshift("-*");
setupVisibility(conf);

// Resolve eventual colors setup (as in debug lib)
if (supportsColor && process.env.LOG4_COLORS !== "no") {
	var colors;
	if (supportsColor.level >= 2) {
		colors = [
			20,
			21,
			26,
			27,
			32,
			33,
			38,
			39,
			40,
			41,
			42,
			43,
			44,
			45,
			56,
github alex-saunders / glicky / src / server / eventHandlers / processes / processManager.js View on Github external
execute() {
    if (!this.initCommand) return;

    const env = Object.assign({}, process.env);
    const pathVariableName = getPathVariableName();
    // Using process.cwd until a better solution is found for (#5)
    env[pathVariableName] +=
      (isWin() ? ';' : ':') + process.cwd() + '/node_modules/.bin';
    this.proc = cp.spawn(this.initCommand, [], {
      env: Object.assign({ FORCE_COLOR: supportsColor.level }, env),
      shell: true
    });

    this.proc.stdout.setEncoding('utf8');
    this.proc.stderr.setEncoding('utf8');
    // this.proc && this.proc.stdin.setEncoding('utf-8');

    this.executing = true;
    this.setupEvents();

    this.pid = this.proc.pid;
  }
}
github kube-HPC / hkube / core / algorithm-builder / builders / environments / nodejs / node_modules / debug / src / node.js View on Github external
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;

/**
 * Colors.
 */

exports.colors = [ 6, 2, 3, 4, 5, 1 ];

try {
  var supportsColor = require('supports-color');
  if (supportsColor && supportsColor.level >= 2) {
    exports.colors = [
      20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
      69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
      135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
      172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
      205, 206, 207, 208, 209, 214, 215, 220, 221
    ];
  }
} catch (err) {
  // swallow - we only care if `supports-color` is available; it doesn't have to be.
}

/**
 * Build up the default `inspectOpts` object from the environment variables.
 *
 *   $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
github ENaranjo95 / 21Savage / .gitignore / node_modules / chalk / index.js View on Github external
function applyOptions(obj, options) {
	options = options || {};

	// Detect level if not set manually
	const scLevel = supportsColor ? supportsColor.level : 0;
	obj.level = options.level === undefined ? scLevel : options.level;
	obj.enabled = 'enabled' in options ? options.enabled : obj.level > 0;
}
github onmyway133 / PushNotifications / node_modules / debug / src / node.js View on Github external
exports.init = init;
exports.log = log;
exports.formatArgs = formatArgs;
exports.save = save;
exports.load = load;
exports.useColors = useColors;

/**
 * Colors.
 */

exports.colors = [ 6, 2, 3, 4, 5, 1 ];

try {
  var supportsColor = require('supports-color');
  if (supportsColor && supportsColor.level >= 2) {
    exports.colors = [
      20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
      69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
      135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
      172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
      205, 206, 207, 208, 209, 214, 215, 220, 221
    ];
  }
} catch (err) {
  // swallow - we only care if `supports-color` is available; it doesn't have to be.
}

/**
 * Build up the default `inspectOpts` object from the environment variables.
 *
 *   $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
github weixu365 / serverless-scriptable-plugin / test / scripts / check-is-support-colors.js View on Github external
const supportsColor = require('supports-color');

console.log(`check if support colors in current process? ${JSON.stringify(supportsColor)}`);
serverless.supportColorLevel = supportsColor.level;

if (supportsColor.level > 0) {
  console.log('Support colors in current process');
} else {
  console.error('FAILED: DO NOT SUPPORT colors');
}
github d4rkr00t / jest-electron-runner / packages / jest-electron-runner / index.js View on Github external
new Promise((resolve, reject) => {
              if (watcher.isInterrupted()) {
                throw new CancelRun();
              }

              const env = Object.assign({}, process.env, {
                FORCE_COLOR: supportsColor.level
              });

              onStart(test)
                .then(() =>
                  spawn(
                    electron,
                    [path.join(__dirname, "electron-transport.js")],
                    { stdio: ["ipc"], env }
                  )
                )
                .then(electron => {
                  process.on("exit", code => {
                    electron.kill();
                  });

                  electron.on("message", message => {
github release-it / release-it / lib / metrics.js View on Github external
const uuid = require('uuid');
const osName = require('os-name');
const isCi = require('is-ci');
const _ = require('lodash');
const debug = require('debug')('release-it:metrics');
const pkg = require('../package.json');

const noop = Promise.resolve();

const cast = value => (value ? 1 : 0);

const cid = uuid.v4();
const dimensions = windowSize ? windowSize.get() : { width: 0, height: 0 };
const vp = `${dimensions.width}x${dimensions.height}`;
const depths = ['1-bit', '4-bit', '8-bit', '24-bits'];
const sd = depths[supportsColor.level || 0];

const payload = config => ({
  v: 1,
  tid: 'UA-108828841-1',
  cid,
  vp,
  sd,
  cd1: pkg.version,
  cd2: process.version,
  cd3: osName(),
  cd4: cast(!config.isCI),
  cd5: cast(config.isDryRun),
  cd6: cast(config.isVerbose),
  cd7: cast(config.isDebug),
  cd8: null,
  cd9: config.preReleaseId,