@@ -122,12 +122,14 @@ class UI {
122
122
} ) ;
123
123
}
124
124
125
- log ( message , color ) {
125
+ log ( message , color , stderr ) {
126
126
if ( color ) {
127
127
message = chalk [ color ] ( message ) ;
128
128
}
129
129
130
- this . stdout . write ( `${ this . spinner ? '\r' : '' } ${ message } \n` ) ;
130
+ let stream = stderr ? 'stderr' : 'stdout' ;
131
+
132
+ this [ stream ] . write ( `${ this . spinner ? '\r' : '' } ${ message } \n` ) ;
131
133
}
132
134
133
135
success ( message ) {
@@ -157,7 +159,7 @@ class UI {
157
159
let verboseOutput = error . toString ( true ) ;
158
160
159
161
// Log the verbose error if verbose is set, otherwise log the non-verbose error output
160
- this . log ( this . verbose ? verboseOutput : error . toString ( false ) ) ;
162
+ this . log ( this . verbose ? verboseOutput : error . toString ( false ) , null , true ) ;
161
163
this . log ( debugInfo , 'yellow' ) ;
162
164
163
165
if ( error . logToFile ( ) ) {
@@ -168,7 +170,7 @@ class UI {
168
170
let output = `An error occurred.\n${ chalk . yellow ( 'Message:' ) } '${ error . message } '\n\n` ;
169
171
170
172
if ( ! this . verbose ) {
171
- this . log ( output , 'red' ) ;
173
+ this . log ( output , 'red' , true ) ;
172
174
}
173
175
174
176
if ( error . stack ) {
@@ -184,17 +186,17 @@ class UI {
184
186
}
185
187
186
188
if ( this . verbose ) {
187
- this . log ( output , 'red' ) ;
189
+ this . log ( output , 'red' , true ) ;
188
190
}
189
191
190
192
this . log ( debugInfo , 'yellow' ) ;
191
193
this . _logErrorToFile ( `${ debugInfo } \n${ output } ` ) ;
192
194
} else if ( isObject ( error ) ) {
193
195
// TODO: find better way to handle object errors?
194
- this . log ( JSON . stringify ( error ) ) ;
196
+ this . log ( JSON . stringify ( error ) , null , true ) ;
195
197
} else if ( error !== false ) {
196
198
// If the error is false, we're just exiting (makes the promise chains easier)
197
- this . log ( 'An unknown error occured.' ) ;
199
+ this . log ( 'An unknown error occured.' , null , true ) ;
198
200
}
199
201
}
200
202
0 commit comments