diff options
Diffstat (limited to 'tools/eslint/node_modules/chalk/index.js')
-rw-r--r-- | tools/eslint/node_modules/chalk/index.js | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/tools/eslint/node_modules/chalk/index.js b/tools/eslint/node_modules/chalk/index.js index 4138a64dd9..2d85a91747 100644 --- a/tools/eslint/node_modules/chalk/index.js +++ b/tools/eslint/node_modules/chalk/index.js @@ -5,6 +5,7 @@ var stripAnsi = require('strip-ansi'); var hasAnsi = require('has-ansi'); var supportsColor = require('supports-color'); var defineProps = Object.defineProperties; +var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM); function Chalk(options) { // detect mode if not set manually @@ -12,22 +13,10 @@ function Chalk(options) { } // use bright blue on Windows as the normal blue color is illegible -if (process.platform === 'win32') { +if (isSimpleWindowsTerm) { ansiStyles.blue.open = '\u001b[94m'; } -function build(_styles) { - var builder = function builder() { - return applyStyle.apply(builder, arguments); - }; - builder._styles = _styles; - builder.enabled = this.enabled; - // __proto__ is used because we must return a function, but there is - // no way to create a function with a different prototype. - builder.__proto__ = proto; - return builder; -} - var styles = (function () { var ret = {}; @@ -46,11 +35,27 @@ var styles = (function () { var proto = defineProps(function chalk() {}, styles); +function build(_styles) { + var builder = function () { + return applyStyle.apply(builder, arguments); + }; + + builder._styles = _styles; + builder.enabled = this.enabled; + // __proto__ is used because we must return a function, but there is + // no way to create a function with a different prototype. + /* eslint-disable no-proto */ + builder.__proto__ = proto; + + return builder; +} + function applyStyle() { // support varags, but simply cast to string in case there's only one arg var args = arguments; var argsLen = args.length; var str = argsLen !== 0 && String(arguments[0]); + if (argsLen > 1) { // don't slice `arguments`, it prevents v8 optimizations for (var a = 1; a < argsLen; a++) { @@ -62,18 +67,29 @@ function applyStyle() { return str; } - /*jshint validthis: true */ var nestedStyles = this._styles; - var i = nestedStyles.length; + + // Turns out that on Windows dimmed gray text becomes invisible in cmd.exe, + // see https://github.com/chalk/chalk/issues/58 + // If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop. + var originalDim = ansiStyles.dim.open; + if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) { + ansiStyles.dim.open = ''; + } + while (i--) { var code = ansiStyles[nestedStyles[i]]; + // Replace any instances already present with a re-opening code // otherwise only the part of the string until said closing code // will be colored, and the rest will simply be 'plain'. str = code.open + str.replace(code.closeRe, code.open) + code.close; } + // Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue. + ansiStyles.dim.open = originalDim; + return str; } |