2 var argv = process.argv;
4 var terminator = argv.indexOf('--');
5 var hasFlag = function (flag) {
7 var pos = argv.indexOf(flag);
8 return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
11 module.exports = (function () {
12 if ('FORCE_COLOR' in process.env) {
16 if (hasFlag('no-color') ||
17 hasFlag('no-colors') ||
18 hasFlag('color=false')) {
22 if (hasFlag('color') ||
24 hasFlag('color=true') ||
25 hasFlag('color=always')) {
29 if (process.stdout && !process.stdout.isTTY) {
33 if (process.platform === 'win32') {
37 if ('COLORTERM' in process.env) {
41 if (process.env.TERM === 'dumb') {
45 if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {