Skip to content

Commit 4bd568e

Browse files
committed
Validate that checkPaths exist
1 parent bdbd214 commit 4bd568e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

plugin/pluginCore.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { extname } = require('path')
22

33
const pa11y = require('pa11y');
44
const readdirp = require('readdirp')
5-
const { isDirectory } = require('path-type')
5+
const { isDirectory, isFile } = require('path-type')
66

77
exports.runPa11y = async function({ htmlFilePaths, testMode, debugMode }) {
88
let results = await Promise.all(htmlFilePaths.map(pa11y));
@@ -43,6 +43,11 @@ const findHtmlFiles = async function(fileAndDirPath) {
4343
return fileInfos.map(({ fullPath }) => fullPath)
4444
}
4545

46+
if (!(await isFile(fileAndDirPath))) {
47+
console.warn(`Folder ${fileAndDirPath} was provided in "checkPaths", but does not exist - it either indicates something went wrong with your build, or you can simply delete this folder from your "checkPaths" in netlify.toml`)
48+
return []
49+
}
50+
4651
if (extname(fileAndDirPath) !== '.html') {
4752
return []
4853
}

0 commit comments

Comments
 (0)