File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -129,6 +129,7 @@ function padRight(value, minimum) {
129
129
* @param {Object } [options.silent=false] - Do not output
130
130
* messages without `fatal` set to true. Also sets
131
131
* `quiet` to `true`.
132
+ * @param {Object } [options.verbose=false] - Output notes.
132
133
* @return {string } - Formatted files.
133
134
*/
134
135
function reporter ( files , options ) {
@@ -139,6 +140,7 @@ function reporter(files, options) {
139
140
var listing = false ;
140
141
var summaryColor ;
141
142
var summary ;
143
+ var verbose ;
142
144
143
145
if ( ! files ) {
144
146
return '' ;
@@ -152,6 +154,8 @@ function reporter(files, options) {
152
154
options = { } ;
153
155
}
154
156
157
+ verbose = options . verbose || false ;
158
+
155
159
if ( options . silent ) {
156
160
removeNonFatalMessages ( files ) ;
157
161
}
@@ -214,6 +218,10 @@ function reporter(files, options) {
214
218
reason = message . stack ;
215
219
}
216
220
221
+ if ( verbose && message . note ) {
222
+ reason += '\n' + message . note ;
223
+ }
224
+
217
225
return [
218
226
'' ,
219
227
padLeft ( location , POSITION_LENGTH ) ,
Original file line number Diff line number Diff line change @@ -217,6 +217,34 @@ describe('vfile-reporter', function () {
217
217
] . join ( '\n' ) ) ;
218
218
} ) ;
219
219
220
+ it ( 'should support `note` in verbose mode' , function ( ) {
221
+ var file = toVFile ( 'a.js' ) ;
222
+ var warning = file . warn ( 'Whoops' ) ;
223
+
224
+ warning . note = [
225
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ' ,
226
+ 'nulla tellus, ornare sed auctor nec, feugiat sit amet justo. ' ,
227
+ '' ,
228
+ 'See http://lipsum.com for more information.'
229
+ ] . join ( '\n' ) ;
230
+
231
+ file . warn ( '...and some more warnings' ) ;
232
+
233
+ equal ( clean ( reporter ( file , {
234
+ 'verbose' : true
235
+ } ) ) , [
236
+ 'a.js' ,
237
+ ' 1:1 warning Whoops' ,
238
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut ' ,
239
+ 'nulla tellus, ornare sed auctor nec, feugiat sit amet justo. ' ,
240
+ '' ,
241
+ 'See http://lipsum.com for more information.' ,
242
+ ' 1:1 warning ...and some more warnings' ,
243
+ '' ,
244
+ '⚠ 2 warnings'
245
+ ] . join ( '\n' ) ) ;
246
+ } ) ;
247
+
220
248
it ( 'should ignore successful files in `quiet` mode' , function ( ) {
221
249
var a = toVFile ( 'a.js' ) ;
222
250
var b = toVFile ( 'b.js' ) ;
You can’t perform that action at this time.
0 commit comments