diff options
Diffstat (limited to 'node_modules/supports-color/index.js')
-rw-r--r-- | node_modules/supports-color/index.js | 65 |
1 files changed, 16 insertions, 49 deletions
diff --git a/node_modules/supports-color/index.js b/node_modules/supports-color/index.js index 113040d63..a2b978450 100644 --- a/node_modules/supports-color/index.js +++ b/node_modules/supports-color/index.js @@ -1,72 +1,39 @@ 'use strict'; -var hasFlag = require('has-flag'); +var argv = process.argv; -var support = function (level) { - if (level === 0) { +module.exports = (function () { + if (argv.indexOf('--no-color') !== -1 || + argv.indexOf('--no-colors') !== -1 || + argv.indexOf('--color=false') !== -1) { return false; } - return { - level: level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3 - }; -}; - -var supportLevel = (function () { - if (hasFlag('no-color') || - hasFlag('no-colors') || - hasFlag('color=false')) { - return 0; - } - - if (hasFlag('color=16m') || - hasFlag('color=full') || - hasFlag('color=truecolor')) { - return 3; - } - - if (hasFlag('color=256')) { - return 2; - } - - if (hasFlag('color') || - hasFlag('colors') || - hasFlag('color=true') || - hasFlag('color=always')) { - return 1; + if (argv.indexOf('--color') !== -1 || + argv.indexOf('--colors') !== -1 || + argv.indexOf('--color=true') !== -1 || + argv.indexOf('--color=always') !== -1) { + return true; } if (process.stdout && !process.stdout.isTTY) { - return 0; + return false; } if (process.platform === 'win32') { - return 1; + return true; } if ('COLORTERM' in process.env) { - return 1; + return true; } if (process.env.TERM === 'dumb') { - return 0; - } - - if (/^xterm-256(?:color)?/.test(process.env.TERM)) { - return 2; + return false; } if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { - return 1; + return true; } - return 0; + return false; })(); - -if (supportLevel === 0 && 'FORCE_COLOR' in process.env) { - supportLevel = 1; -} - -module.exports = process && support(supportLevel); |