diff options
author | Kat Marchán <kzm@zkat.tech> | 2018-08-29 12:03:09 -0700 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-09-02 12:51:59 +0200 |
commit | 78f5685acc8fa574c32ed60d07de6273c60639b9 (patch) | |
tree | c3381e90e1c734763d98f079aad5d5f45438ca6d /deps/npm/node_modules/colors/lib/system/supports-colors.js | |
parent | 1287e524eeba4632decce231da161426efb8fc34 (diff) | |
download | android-node-v8-78f5685acc8fa574c32ed60d07de6273c60639b9.tar.gz android-node-v8-78f5685acc8fa574c32ed60d07de6273c60639b9.tar.bz2 android-node-v8-78f5685acc8fa574c32ed60d07de6273c60639b9.zip |
deps: upgrade npm to 6.4.1
PR-URL: https://github.com/nodejs/node/pull/22591
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'deps/npm/node_modules/colors/lib/system/supports-colors.js')
-rw-r--r-- | deps/npm/node_modules/colors/lib/system/supports-colors.js | 128 |
1 files changed, 19 insertions, 109 deletions
diff --git a/deps/npm/node_modules/colors/lib/system/supports-colors.js b/deps/npm/node_modules/colors/lib/system/supports-colors.js index f1f9c8ff3d..3e008aa93a 100644 --- a/deps/npm/node_modules/colors/lib/system/supports-colors.js +++ b/deps/npm/node_modules/colors/lib/system/supports-colors.js @@ -23,129 +23,39 @@ THE SOFTWARE. */ -'use strict'; +var argv = process.argv; -var os = require('os'); -var hasFlag = require('./has-flag.js'); - -var env = process.env; - -var forceColor = void 0; -if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false')) { - forceColor = false; -} else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') - || hasFlag('color=always')) { - forceColor = true; -} -if ('FORCE_COLOR' in env) { - forceColor = env.FORCE_COLOR.length === 0 - || parseInt(env.FORCE_COLOR, 10) !== 0; -} - -function translateLevel(level) { - if (level === 0) { +module.exports = (function () { + if (argv.indexOf('--no-color') !== -1 || + argv.indexOf('--color=false') !== -1) { return false; } - return { - level: level, - hasBasic: true, - has256: level >= 2, - has16m: level >= 3, - }; -} - -function supportsColor(stream) { - if (forceColor === false) { - return 0; - } - - if (hasFlag('color=16m') || hasFlag('color=full') - || hasFlag('color=truecolor')) { - return 3; + if (argv.indexOf('--color') !== -1 || + argv.indexOf('--color=true') !== -1 || + argv.indexOf('--color=always') !== -1) { + return true; } - if (hasFlag('color=256')) { - return 2; - } - - if (stream && !stream.isTTY && forceColor !== true) { - return 0; + if (process.stdout && !process.stdout.isTTY) { + return false; } - var min = forceColor ? 1 : 0; - if (process.platform === 'win32') { - // Node.js 7.5.0 is the first version of Node.js to include a patch to - // libuv that enables 256 color output on Windows. Anything earlier and it - // won't work. However, here we target Node.js 8 at minimum as it is an LTS - // release, and Node.js 7 is not. Windows 10 build 10586 is the first - // Windows release that supports 256 colors. Windows 10 build 14931 is the - // first release that supports 16m/TrueColor. - var osRelease = os.release().split('.'); - if (Number(process.versions.node.split('.')[0]) >= 8 - && Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) { - return Number(osRelease[2]) >= 14931 ? 3 : 2; - } - - return 1; - } - - if ('CI' in env) { - if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(function(sign) { - return sign in env; - }) || env.CI_NAME === 'codeship') { - return 1; - } - - return min; - } - - if ('TEAMCITY_VERSION' in env) { - return (/^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0 - ); - } - - if ('TERM_PROGRAM' in env) { - var version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10); - - switch (env.TERM_PROGRAM) { - case 'iTerm.app': - return version >= 3 ? 3 : 2; - case 'Hyper': - return 3; - case 'Apple_Terminal': - return 2; - // No default - } - } - - if (/-256(color)?$/i.test(env.TERM)) { - return 2; + return true; } - if (/^screen|^xterm|^vt100|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) { - return 1; + if ('COLORTERM' in process.env) { + return true; } - if ('COLORTERM' in env) { - return 1; + if (process.env.TERM === 'dumb') { + return false; } - if (env.TERM === 'dumb') { - return min; + if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { + return true; } - return min; -} - -function getSupportLevel(stream) { - var level = supportsColor(stream); - return translateLevel(level); -} - -module.exports = { - supportsColor: getSupportLevel, - stdout: getSupportLevel(process.stdout), - stderr: getSupportLevel(process.stderr), -}; + return false; +})();
\ No newline at end of file |