Update supports-colors.js

This commit is contained in:
paladox 2016-09-22 16:24:11 +01:00 committed by GitHub
parent 9f3ace4470
commit c74f2c3088

View File

@ -1,61 +1,73 @@
/* 'use strict';
The MIT License (MIT) var hasFlag = require('has-flag');
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) var support = function (level) {
if (level === 0) {
return false;
}
Permission is hereby granted, free of charge, to any person obtaining a copy return {
of this software and associated documentation files (the "Software"), to deal level: level,
in the Software without restriction, including without limitation the rights hasBasic: true,
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell has256: level >= 2,
copies of the Software, and to permit persons to whom the Software is has16m: level >= 3
furnished to do so, subject to the following conditions: };
};
The above copyright notice and this permission notice shall be included in var supportLevel = (function () {
all copies or substantial portions of the Software. if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return 0;
}
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR if (hasFlag('color=16m') ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, hasFlag('color=full') ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE hasFlag('color=truecolor')) {
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER return 3;
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, }
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/ if (hasFlag('color=256')) {
return 2;
}
var argv = process.argv; if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return 1;
}
module.exports = (function () { if (process.stdout && !process.stdout.isTTY) {
if (argv.indexOf('--no-color') !== -1 || return 0;
argv.indexOf('--color=false') !== -1) { }
return false;
}
if (argv.indexOf('--color') !== -1 || if (process.platform === 'win32') {
argv.indexOf('--color=true') !== -1 || return 1;
argv.indexOf('--color=always') !== -1) { }
return true;
}
if (process.stdout && !process.stdout.isTTY) { if ('COLORTERM' in process.env) {
return false; return 1;
} }
if (process.platform === 'win32') { if (process.env.TERM === 'dumb') {
return true; return 0;
} }
if ('COLORTERM' in process.env) { if (/^xterm-256(?:color)?/.test(process.env.TERM)) {
return true; return 2;
} }
if (process.env.TERM === 'dumb') { if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return false; return 1;
} }
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { return 0;
return true; })();
}
if (supportLevel === 0 && 'FORCE_COLOR' in process.env) {
supportLevel = 1;
}
module.exports = process && support(supportLevel);
return false;
})();