You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
901 B
50 lines
901 B
'use strict'; |
|
var argv = process.argv; |
|
|
|
var terminator = argv.indexOf('--'); |
|
var hasFlag = function (flag) { |
|
flag = '--' + flag; |
|
var pos = argv.indexOf(flag); |
|
return pos !== -1 && (terminator !== -1 ? pos < terminator : true); |
|
}; |
|
|
|
module.exports = (function () { |
|
if ('FORCE_COLOR' in process.env) { |
|
return true; |
|
} |
|
|
|
if (hasFlag('no-color') || |
|
hasFlag('no-colors') || |
|
hasFlag('color=false')) { |
|
return false; |
|
} |
|
|
|
if (hasFlag('color') || |
|
hasFlag('colors') || |
|
hasFlag('color=true') || |
|
hasFlag('color=always')) { |
|
return true; |
|
} |
|
|
|
if (process.stdout && !process.stdout.isTTY) { |
|
return false; |
|
} |
|
|
|
if (process.platform === 'win32') { |
|
return true; |
|
} |
|
|
|
if ('COLORTERM' in process.env) { |
|
return true; |
|
} |
|
|
|
if (process.env.TERM === 'dumb') { |
|
return false; |
|
} |
|
|
|
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { |
|
return true; |
|
} |
|
|
|
return false; |
|
})();
|
|
|