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.

index.js 901B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. var argv = process.argv;
  3. var terminator = argv.indexOf('--');
  4. var hasFlag = function (flag) {
  5. flag = '--' + flag;
  6. var pos = argv.indexOf(flag);
  7. return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
  8. };
  9. module.exports = (function () {
  10. if ('FORCE_COLOR' in process.env) {
  11. return true;
  12. }
  13. if (hasFlag('no-color') ||
  14. hasFlag('no-colors') ||
  15. hasFlag('color=false')) {
  16. return false;
  17. }
  18. if (hasFlag('color') ||
  19. hasFlag('colors') ||
  20. hasFlag('color=true') ||
  21. hasFlag('color=always')) {
  22. return true;
  23. }
  24. if (process.stdout && !process.stdout.isTTY) {
  25. return false;
  26. }
  27. if (process.platform === 'win32') {
  28. return true;
  29. }
  30. if ('COLORTERM' in process.env) {
  31. return true;
  32. }
  33. if (process.env.TERM === 'dumb') {
  34. return false;
  35. }
  36. if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
  37. return true;
  38. }
  39. return false;
  40. })();