|
1 | 1 | /**
|
2 |
| - * Reads account information from env variables or .zat file |
| 2 | + * Reads account information from env variables or .a11yrc.json file |
3 | 3 | */
|
4 |
| -const zatAccount = require("./zat"); |
| 4 | +const fs = require("fs"); |
| 5 | + |
| 6 | +let a11yAccount = {}; |
| 7 | +const a11yrcFilePath = ".a11yrc.json"; |
| 8 | + |
| 9 | +if (fs.existsSync(a11yrcFilePath)) { |
| 10 | + a11yAccount = JSON.parse(fs.readFileSync(a11yrcFilePath)); |
| 11 | +} |
5 | 12 |
|
6 | 13 | function isValid(account) {
|
7 | 14 | return account.subdomain && account.email && account.password;
|
8 | 15 | }
|
9 | 16 |
|
10 | 17 | function getAccount() {
|
11 |
| - // Reads account from the env or .zat file if present |
| 18 | + // Reads account from the env or .a11yrc.json file if present |
12 | 19 | let account = {
|
13 |
| - subdomain: process.env.subdomain || zatAccount.subdomain, |
14 |
| - email: process.env.end_user_email || zatAccount.username, |
15 |
| - password: process.env.end_user_password || zatAccount.password, |
16 |
| - urls: process.env?.urls?.trim()?.split(/\s+/) || zatAccount.urls |
| 20 | + subdomain: process.env.subdomain || a11yAccount.subdomain, |
| 21 | + email: process.env.end_user_email || a11yAccount.username, |
| 22 | + password: process.env.end_user_password || a11yAccount.password, |
| 23 | + urls: process.env?.urls?.trim()?.split(/\s+/) || a11yAccount.urls |
17 | 24 | };
|
18 | 25 |
|
19 | 26 | if (!isValid(account)) {
|
20 | 27 | console.error(
|
21 |
| - "No account specified. Please create a .zat file or set subdomain, end_user_email and end_user_password as environment variables" |
| 28 | + "No account specified. Please create a .a11yrc.json file or set subdomain, end_user_email and end_user_password as environment variables" |
22 | 29 | );
|
23 | 30 | process.exit(1);
|
24 | 31 | }
|
|
0 commit comments