2 var hasFlag = require('has-flag');
4 var support = function (level) {
17 var supportLevel = (function () {
18 if (hasFlag('no-color') ||
19 hasFlag('no-colors') ||
20 hasFlag('color=false')) {
24 if (hasFlag('color=16m') ||
25 hasFlag('color=full') ||
26 hasFlag('color=truecolor')) {
30 if (hasFlag('color=256')) {
34 if (hasFlag('color') ||
36 hasFlag('color=true') ||
37 hasFlag('color=always')) {
41 if (process.stdout && !process.stdout.isTTY) {
45 if (process.platform === 'win32') {
49 if ('CI' in process.env) {
50 if ('TRAVIS' in process.env || process.env.CI === 'Travis') {
57 if ('TEAMCITY_VERSION' in process.env) {
58 return process.env.TEAMCITY_VERSION.match(/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/) === null ? 0 : 1;
61 if (/^(screen|xterm)-256(?:color)?/.test(process.env.TERM)) {
65 if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
69 if ('COLORTERM' in process.env) {
73 if (process.env.TERM === 'dumb') {
80 if (supportLevel === 0 && 'FORCE_COLOR' in process.env) {
84 module.exports = process && support(supportLevel);