@@ -7,6 +7,9 @@ const { results: cliReporter } = require('pa11y/lib/reporters/cli')
7
7
const readdirp = require ( 'readdirp' )
8
8
9
9
const EMPTY_ARRAY = [ ]
10
+ const ASTERISK = '*'
11
+ const HTML_EXT = '.html'
12
+ const GLOB_HTML = '*.html'
10
13
11
14
exports . runPa11y = async function ( { htmlFilePaths, pa11yOpts, build } ) {
12
15
let issueCount = 0
@@ -47,11 +50,17 @@ exports.generateFilePaths = async function ({
47
50
48
51
const findHtmlFiles = async function ( fileAndDirPath , directoryFilter ) {
49
52
if ( await isDirectory ( fileAndDirPath ) ) {
50
- const fileInfos = await readdirp . promise ( fileAndDirPath , {
51
- fileFilter : '*.html' ,
52
- directoryFilter : ! ! directoryFilter . length ? directoryFilter : '*' ,
53
+ const filePaths = [ ]
54
+ const stream = readdirp ( fileAndDirPath , {
55
+ fileFilter : GLOB_HTML ,
56
+ directoryFilter : ! ! directoryFilter . length ? directoryFilter : ASTERISK ,
53
57
} )
54
- return fileInfos . map ( ( { fullPath } ) => fullPath )
58
+
59
+ for await ( const { fullPath } of stream ) {
60
+ filePaths . push ( fullPath )
61
+ }
62
+
63
+ return filePaths
55
64
}
56
65
57
66
if ( ! ( await isFile ( fileAndDirPath ) ) ) {
@@ -61,7 +70,7 @@ const findHtmlFiles = async function (fileAndDirPath, directoryFilter) {
61
70
return EMPTY_ARRAY
62
71
}
63
72
64
- if ( extname ( fileAndDirPath ) !== '.html' ) {
73
+ if ( extname ( fileAndDirPath ) !== HTML_EXT ) {
65
74
return EMPTY_ARRAY
66
75
}
67
76
0 commit comments