@@ -2,7 +2,7 @@ const { extname } = require('path')
2
2
3
3
const pa11y = require ( 'pa11y' ) ;
4
4
const readdirp = require ( 'readdirp' )
5
- const { isDirectory } = require ( 'path-type' )
5
+ const { isDirectory, isFile } = require ( 'path-type' )
6
6
7
7
exports . runPa11y = async function ( { htmlFilePaths, testMode, debugMode } ) {
8
8
let results = await Promise . all ( htmlFilePaths . map ( pa11y ) ) ;
@@ -28,21 +28,26 @@ exports.runPa11y = async function({ htmlFilePaths, testMode, debugMode }) {
28
28
exports . generateFilePaths = async function ( {
29
29
fileAndDirPaths, // array, mix of html and directories
30
30
PUBLISH_DIR ,
31
+ build,
31
32
testMode,
32
33
debugMode
33
34
} ) {
34
35
const htmlFilePaths = await Promise . all (
35
- fileAndDirPaths . map ( fileAndDirPath => findHtmlFiles ( `${ PUBLISH_DIR } /${ fileAndDirPath } ` ) )
36
+ fileAndDirPaths . map ( fileAndDirPath => findHtmlFiles ( `${ PUBLISH_DIR } /${ fileAndDirPath } ` , build ) )
36
37
)
37
38
return [ ] . concat ( ...htmlFilePaths )
38
39
} ;
39
40
40
- const findHtmlFiles = async function ( fileAndDirPath ) {
41
+ const findHtmlFiles = async function ( fileAndDirPath , build ) {
41
42
if ( await isDirectory ( fileAndDirPath ) ) {
42
43
const fileInfos = await readdirp . promise ( fileAndDirPath , { fileFilter : '*.html' } )
43
44
return fileInfos . map ( ( { fullPath } ) => fullPath )
44
45
}
45
46
47
+ if ( ! ( await isFile ( fileAndDirPath ) ) ) {
48
+ build . failBuild ( `Input "checkPaths" does not exist: ${ fileAndDirPath } ` )
49
+ }
50
+
46
51
if ( extname ( fileAndDirPath ) !== '.html' ) {
47
52
return [ ]
48
53
}
0 commit comments