-
Notifications
You must be signed in to change notification settings - Fork 3
/
pa11yci.conf.js
executable file
·50 lines (44 loc) · 1.18 KB
/
pa11yci.conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*!
Pa11y-ci Configuration.
Dynamically generate a '.pa11yci' JSON config object, using an environment variable.
*/
var defaults = {
standard: "WCAG2AA",
timeout: 5000,
runners: ["axe", "htmlcs"],
page: {
viewport: {
width: 1280,
height: 1024
}
}
};
function pa11yCiConfiguration() {
const fs = require("fs");
var target = "";
// If TARGET environment variable is set, use that as a base for URLs.
if (process.env.TARGET) {
target = process.env.TARGET;
}
var urls = [target];
// If a pages.txt file is available, use that to generate a list of URLs.
let pages = "pages.txt";
if (fs.existsSync(pages)) {
urls = [];
var lines = fs
.readFileSync(pages, "utf-8")
.split("\n")
.filter(Boolean);
for (var line of lines) {
// Trim trailing/leading slashes from the target and path, just in case.
urls.push(target.replace(/[/]$/, "") + "/" + line.replace(/^[/]/, ""));
}
}
console.log(urls);
return {
defaults: defaults,
urls: urls
};
}
// Important ~ call the function, don't return a reference to it!
module.exports = pa11yCiConfiguration();