-
Notifications
You must be signed in to change notification settings - Fork 52
/
cli-options-filter.js
41 lines (33 loc) · 1.01 KB
/
cli-options-filter.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
'use strict';
const Filter = require('broccoli-persistent-filter');
const enableMiddlewareReporter =
process.env.ENABLE_A11Y_MIDDLEWARE_REPORTER === 'true';
const enableA11yAudit = process.env.ENABLE_A11Y_AUDIT === 'true';
const replacementToken = '$1 true';
class CliOptionsFilter extends Filter {
constructor() {
super(...arguments);
}
/**
* If `ENABLE_A11Y_MIDDLEWARE_REPORTER=true` or `ENABLE_A11Y_AUDIT=true` environmental
* variables are specified, overwrite the corresponding values in `test-support/cli-options`
* at build-time to make them accessible in the browser environment.
* @override
*/
processString(contents) {
if (enableMiddlewareReporter) {
contents = contents.replace(
/(ENABLE_A11Y_MIDDLEWARE_REPORTER = )false/,
replacementToken,
);
}
if (enableA11yAudit) {
contents = contents.replace(
/(ENABLE_A11Y_AUDIT = )false/,
replacementToken,
);
}
return contents;
}
}
module.exports = CliOptionsFilter;