File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ export async function log(context, settings) {
3636 func = settings . reporter
3737 }
3838
39- let diagnostics = func (
39+ let diagnostics = await func (
4040 context . files . filter (
4141 ( file ) => file . data . unifiedEngineGiven && ! file . data . unifiedEngineIgnored
4242 ) ,
Original file line number Diff line number Diff line change 1717 * @callback VFileReporter
1818 * @param {Array<VFile> } files
1919 * @param {VFileReporterOptions } options
20- * @returns {string }
20+ * @returns {string | Promise<string> }
2121 *
2222 * @typedef Settings
2323 * @property {Options['processor'] } processor
Original file line number Diff line number Diff line change @@ -18,6 +18,9 @@ const windows = process.platform === 'win32'
1818const cross = windows ? '×' : '✖'
1919const danger = windows ? '‼' : '⚠'
2020
21+ /** @type {import('unified-engine').VFileReporter } */
22+ const vfileReporterPrettyAsync = async ( files ) => vfileReporterPretty ( files )
23+
2124// See: <https://github.com/sindresorhus/eslint-formatter-pretty/blob/159b30a/index.js#L90-L93>.
2225const original = process . env . CI
2326
@@ -169,6 +172,29 @@ test('reporting', async () => {
169172 )
170173 } )
171174
175+ await new Promise ( ( resolve ) => {
176+ const stderr = spy ( )
177+
178+ engine (
179+ {
180+ processor : noop ( ) ,
181+ cwd : new URL ( 'two-files/' , fixtures ) ,
182+ streamError : stderr . stream ,
183+ files : [ '.' ] ,
184+ extensions : [ 'txt' ] ,
185+ reporter : vfileReporterPrettyAsync
186+ } ,
187+ ( error , code ) => {
188+ assert . deepEqual (
189+ [ error , code , stripAnsi ( stderr ( ) ) ] ,
190+ [ null , 0 , '' ] ,
191+ 'should support async reporters'
192+ )
193+ resolve ( undefined )
194+ }
195+ )
196+ } )
197+
172198 await new Promise ( ( resolve ) => {
173199 const stderr = spy ( )
174200 const cwd = new URL ( 'two-files/' , fixtures )
You can’t perform that action at this time.
0 commit comments