File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ var help = [
59
59
" --cover-plain Print plain coverage map if detected" ,
60
60
" --cover-html Write coverage map to \"coverage.html\"" ,
61
61
" --cover-json Write unified coverage map to \"coverage.json\"" ,
62
- // " --no-color Don't use terminal colors",
62
+ " --no-color Don't use terminal colors" ,
63
63
" --version Show version" ,
64
64
" -h, --help You're staring at it"
65
65
] . join ( '\n' ) ;
@@ -69,7 +69,8 @@ var options = {
69
69
matcher : / .* / ,
70
70
watch : false ,
71
71
coverage : false ,
72
- isolate : false
72
+ isolate : false ,
73
+ nocolor : ! process . stdout . isTTY
73
74
} ;
74
75
75
76
var files = [ ] ;
@@ -151,6 +152,9 @@ while (arg = argv.shift()) {
151
152
case 'no-color' :
152
153
options . nocolor = true ;
153
154
break ;
155
+ case 'color' :
156
+ options . nocolor = false ;
157
+ break ;
154
158
case 'no-error' :
155
159
options . error = false ;
156
160
break ;
@@ -167,6 +171,11 @@ while (arg = argv.shift()) {
167
171
}
168
172
}
169
173
174
+ if ( options . nocolor ) {
175
+ cutils . nocolor = true ;
176
+ inspect = require ( 'eyes' ) . inspector ( { stream : null , styles : false } ) ;
177
+ }
178
+
170
179
if ( options . supressStdout ) {
171
180
_reporter . setStream && _reporter . setStream ( process . stdout ) ;
172
181
var devNullStream = fs . createWriteStream ( '/dev/null' ) ;
Original file line number Diff line number Diff line change @@ -2,6 +2,9 @@ var eyes = require('eyes').inspector({ stream: null, styles: false });
2
2
3
3
// Stylize a string
4
4
this . stylize = function stylize ( str , style ) {
5
+ if ( module . exports . nocolor )
6
+ return str ;
7
+
5
8
var styles = {
6
9
'bold' : [ 1 , 22 ] ,
7
10
'italic' : [ 3 , 23 ] ,
@@ -85,6 +88,8 @@ this.result = function (event) {
85
88
} ;
86
89
87
90
this . inspect = function inspect ( val ) {
91
+ if ( module . exports . nocolor )
92
+ return eyes ( val ) ;
88
93
return '\033[1m' + eyes ( val ) + '\033[22m' ;
89
94
} ;
90
95
You can’t perform that action at this time.
0 commit comments