How to use the supports-color.supportsColor 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 Qard / onchange / index.js View on Github external
start (cwd, stdout, stderr, jobEnv, onexit) {
    const color = supportsColor(stdout)
    const env = Object.assign({ FORCE_COLOR: color.level }, jobEnv)

    if (this.outpipe) {
      const cmd = this.outpipe(this.options)

      this.log(`executing outpipe "${cmd}"`)
      this.childOutpipe = exec(cmd, { cwd, env })

      // Must pipe stdout and stderr.
      this.childOutpipe.stdout.pipe(stdout, { end: false })
      this.childOutpipe.stderr.pipe(stderr, { end: false })

      this.childOutpipe.on('exit', (code, signal) => {
        this.log(`outpipe ${exitmsg(code, signal)}`)
        this.childOutpipe = undefined
        if (!this.childCommand) return onexit()
github jamestalmage / supports-hyperlinks / index.js View on Github external
const {env} = process;

	if ('FORCE_HYPERLINK' in env) {
		return !(env.FORCE_HYPERLINK.length > 0 && parseInt(env.FORCE_HYPERLINK, 10) === 0);
	}

	if (hasFlag('no-hyperlink') || hasFlag('no-hyperlinks') || hasFlag('hyperlink=false') || hasFlag('hyperlink=never')) {
		return false;
	}

	if (hasFlag('hyperlink=true') || hasFlag('hyperlink=always')) {
		return true;
	}

	// If they specify no colors, they probably don't want hyperlinks.
	if (!supportsColor.supportsColor(stream)) {
		return false;
	}

	if (stream && !stream.isTTY) {
		return false;
	}

	if (process.platform === 'win32') {
		return false;
	}

	if ('CI' in env) {
		return false;
	}

	if ('TEAMCITY_VERSION' in env) {