Skip to content

Commit 2030091

Browse files
committed
debugmode
1 parent fefeea8 commit 2030091

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

netlify.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@
1212
]
1313

1414
# # optional config
15-
# resultMode = "error" # can switch to warn
15+
# resultMode = "error" # can switch to warn
16+
17+
## Developer only
18+
debugMode = true

plugin/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ function netlifyPlugin(conf) {
1212
return {
1313
name: 'netlify-plugin-a11y',
1414
async onPostBuild({
15-
pluginConfig: { checkPaths, resultMode = 'error' },
16-
constants: { BUILD_DIR },
15+
pluginConfig: { checkPaths, resultMode = 'error', debugMode },
16+
constants: { PUBLISH_DIR },
1717
utils: { build }
1818
}) {
1919
if (!checkPaths) {
@@ -23,8 +23,11 @@ function netlifyPlugin(conf) {
2323
}
2424
const htmlFilePaths = await pluginCore.generateFilePaths({
2525
fileAndDirPaths: checkPaths,
26-
BUILD_DIR
26+
PUBLISH_DIR
2727
});
28+
if (debugMode) {
29+
console.log({ htmlFilePaths });
30+
}
2831
const results = await pluginCore.runPa11y({
2932
htmlFilePaths
3033
});

plugin/pluginCore.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,18 @@ exports.runPa11y = async function({ htmlFilePaths, testMode, debugMode }) {
1212

1313
exports.generateFilePaths = async function({
1414
fileAndDirPaths, // array, mix of html and directories
15-
BUILD_DIR,
15+
PUBLISH_DIR,
1616
testMode,
1717
debugMode
1818
}) {
1919
let htmlFilePaths = [];
2020
for (fileAndDirPath of fileAndDirPaths) {
21-
if (fs.statSync(path.join(BUILD_DIR, fileAndDirPath)).isDirectory()) {
22-
let subPaths = await walk(path.join(BUILD_DIR, fileAndDirPath));
21+
const fullDirPath = path.join(process.cwd(), PUBLISH_DIR, fileAndDirPath);
22+
if (fs.statSync(fullDirPath).isDirectory()) {
23+
let subPaths = await walk(fullDirPath);
2324
htmlFilePaths = htmlFilePaths.concat(subPaths);
2425
} else {
25-
htmlFilePaths.push(path.join(BUILD_DIR, fileAndDirPath));
26+
htmlFilePaths.push(fullDirPath);
2627
}
2728
}
2829
return htmlFilePaths;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
const fs = require('fs');
22
const path = require('path');
33

4-
const BUILD_DIR = path.join(__dirname, 'publishDir');
4+
const PUBLISH_DIR = path.join(__dirname, 'publishDir');
55
// actual test
66
const pluginCore = require('../../plugin/pluginCore.js');
77
test('generateFilePaths works', async () => {
88
const results = await pluginCore.generateFilePaths({
99
fileAndDirPaths: ['/blog', '/about.html'],
10-
BUILD_DIR
10+
PUBLISH_DIR
1111
});
1212
expect(results).toMatchSnapshot();
1313
});

0 commit comments

Comments
 (0)