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