@@ -25,6 +25,23 @@ exports.useColors = useColors;
25
25
26
26
exports . colors = [ 6 , 2 , 3 , 4 , 5 , 1 ] ;
27
27
28
+ try {
29
+ var supportsColor = require ( 'supports-color' ) ;
30
+ if ( supportsColor && supportsColor . level >= 2 ) {
31
+ exports . colors = [
32
+ 20 , 21 , 26 , 27 , 32 , 33 , 38 , 39 , 40 , 41 , 42 , 43 , 44 , 45 , 46 , 47 , 48 ,
33
+ 49 , 50 , 51 , 56 , 57 , 62 , 63 , 68 , 69 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 ,
34
+ 82 , 83 , 84 , 85 , 86 , 87 , 92 , 93 , 98 , 99 , 112 , 113 , 118 , 119 , 128 , 129 ,
35
+ 134 , 135 , 148 , 149 , 154 , 155 , 160 , 161 , 162 , 163 , 164 , 165 , 166 , 167 ,
36
+ 168 , 169 , 170 , 171 , 172 , 173 , 178 , 179 , 184 , 185 , 190 , 191 , 196 , 197 ,
37
+ 198 , 199 , 200 , 201 , 202 , 203 , 204 , 205 , 206 , 207 , 208 , 209 , 214 , 215 ,
38
+ 220 , 221 , 226 , 227
39
+ ] ;
40
+ }
41
+ } catch ( err ) {
42
+ // swallow - we only care if `supports-color` is available; it doesn't have to be.
43
+ }
44
+
28
45
/**
29
46
* Build up the default `inspectOpts` object from the environment variables.
30
47
*
@@ -109,7 +126,7 @@ function formatArgs(args) {
109
126
110
127
if ( useColors ) {
111
128
var c = this . color ;
112
- var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m' ;
129
+ var prefix = ' \u001b[3' + ( c <= 16 ? c : '8;5;' + c ) + ';1m' + name + ' ' + '\u001b[0m' ;
113
130
114
131
args [ 0 ] = prefix + args [ 0 ] . split ( '\n' ) . join ( '\n' + prefix ) ;
115
132
args . push ( '\u001b[3' + c + 'm+' + exports . humanize ( this . diff ) + '\u001b[0m' ) ;
0 commit comments