1
- /**
2
- * @typedef {import('vfile-message').VFileMessage } VFileMessage
3
- */
4
-
5
1
import path from 'node:path'
2
+ import process from 'node:process'
6
3
import test from 'tape'
7
4
import strip from 'strip-ansi'
8
5
import { VFile } from 'vfile'
9
- import figures from 'figures'
10
6
import reporterDefault , { reporter } from './index.js'
11
7
8
+ // `log-symbols` without chalk, ignored for Windows:
9
+ /* c8 ignore next 4 */
10
+ const chars =
11
+ process . platform === 'win32'
12
+ ? { error : '×' , warning : '‼' }
13
+ : { error : '✖' , warning : '⚠' }
14
+
12
15
/* eslint-disable no-undef */
13
16
/** @type {Error } */
14
17
let exception
@@ -104,7 +107,7 @@ test('vfile-reporter', (t) => {
104
107
'' ,
105
108
'b.js: no issues found' ,
106
109
'' ,
107
- figures . warning + ' 1 warning'
110
+ chars . warning + ' 1 warning'
108
111
] . join ( '\n' ) ,
109
112
'should work on files with warnings'
110
113
)
@@ -123,7 +126,7 @@ test('vfile-reporter', (t) => {
123
126
'' ,
124
127
'b.js: no issues found' ,
125
128
'' ,
126
- figures . cross + ' 1 error'
129
+ chars . error + ' 1 error'
127
130
] . join ( '\n' ) ,
128
131
'should work on files with errors'
129
132
)
@@ -155,9 +158,9 @@ test('vfile-reporter', (t) => {
155
158
' 1:1 info Another note!' ,
156
159
'' ,
157
160
'6 messages (' +
158
- figures . cross +
161
+ chars . error +
159
162
' 2 errors, ' +
160
- figures . warning +
163
+ chars . warning +
161
164
' 3 warnings)'
162
165
] . join ( '\n' ) ,
163
166
'should work on files with multiple mixed messages'
@@ -175,9 +178,9 @@ test('vfile-reporter', (t) => {
175
178
' 1:1 info Another note!' ,
176
179
'' ,
177
180
'6 messages (' +
178
- figures . cross +
181
+ chars . error +
179
182
' 2 errors, ' +
180
- figures . warning +
183
+ chars . warning +
181
184
' 3 warnings)'
182
185
] . join ( '\n' ) ,
183
186
'should work on files with multiple mixed messages (w/o color)'
@@ -188,7 +191,7 @@ test('vfile-reporter', (t) => {
188
191
189
192
t . equal (
190
193
strip ( reporter ( file ) ) ,
191
- ' warning Warning!\n\n' + figures . warning + ' 1 warning' ,
194
+ ' warning Warning!\n\n' + chars . warning + ' 1 warning' ,
192
195
'should support a missing position'
193
196
)
194
197
@@ -197,7 +200,7 @@ test('vfile-reporter', (t) => {
197
200
198
201
t . equal (
199
202
strip ( reporter ( file ) ) ,
200
- [ ' 3:2 warning Warning!' , '' , figures . warning + ' 1 warning' ] . join ( '\n' ) ,
203
+ [ ' 3:2 warning Warning!' , '' , chars . warning + ' 1 warning' ] . join ( '\n' ) ,
201
204
'should support a single point'
202
205
)
203
206
@@ -209,7 +212,7 @@ test('vfile-reporter', (t) => {
209
212
210
213
t . equal (
211
214
strip ( reporter ( file ) ) ,
212
- [ ' 3:2-4:8 warning Warning!' , '' , figures . warning + ' 1 warning' ] . join (
215
+ [ ' 3:2-4:8 warning Warning!' , '' , chars . warning + ' 1 warning' ] . join (
213
216
'\n'
214
217
) ,
215
218
'should support a location'
@@ -228,7 +231,7 @@ test('vfile-reporter', (t) => {
228
231
'foo.bar' ,
229
232
' 3:2-4:8 warning Warning!' ,
230
233
'' ,
231
- figures . warning + ' 1 warning'
234
+ chars . warning + ' 1 warning'
232
235
] . join ( '\n' ) ,
233
236
'should support a location (#2)'
234
237
)
@@ -326,7 +329,7 @@ test('vfile-reporter', (t) => {
326
329
' 1:1 warning Whoops' ,
327
330
'Lorem ipsum dolor sit amet.' ,
328
331
'' ,
329
- figures . warning + ' 2 warnings'
332
+ chars . warning + ' 2 warnings'
330
333
] . join ( '\n' ) ,
331
334
'should support `note` in verbose mode'
332
335
)
@@ -336,12 +339,9 @@ test('vfile-reporter', (t) => {
336
339
337
340
t . equal (
338
341
strip ( reporter ( [ file , new VFile ( { path : 'b.js' } ) ] , { quiet : true } ) ) ,
339
- [
340
- 'a.js' ,
341
- ' 1:1 warning Warning!' ,
342
- '' ,
343
- figures . warning + ' 1 warning'
344
- ] . join ( '\n' ) ,
342
+ [ 'a.js' , ' 1:1 warning Warning!' , '' , chars . warning + ' 1 warning' ] . join (
343
+ '\n'
344
+ ) ,
345
345
'should ignore successful files in `quiet` mode'
346
346
)
347
347
@@ -356,7 +356,7 @@ test('vfile-reporter', (t) => {
356
356
357
357
t . equal (
358
358
strip ( reporter ( [ file , fileB ] , { silent : true } ) ) ,
359
- [ 'a.js' , ' 1:1 error Error!' , '' , figures . cross + ' 1 error' ] . join ( '\n' ) ,
359
+ [ 'a.js' , ' 1:1 error Error!' , '' , chars . error + ' 1 error' ] . join ( '\n' ) ,
360
360
'should ignore non-failures in `silent` mode'
361
361
)
362
362
0 commit comments