forked from webpack/webpack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.js
More file actions
36 lines (34 loc) · 795 Bytes
/
errors.js
File metadata and controls
36 lines (34 loc) · 795 Bytes
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
const variables = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii'];
const modules = [{
name: 'aaa',
variables: ['aaa']
}, {
name: 'bbbccc',
variables: ['bbb', 'ccc']
}, {
name: 'ddd',
variables: []
}, {
name: 'eeefff',
variables: ['eee', 'fff']
}, {
name: 'ggghhh',
variables: ['ggg', 'hhh']
}, {
name: 'iii',
variables: ['iii']
}];
// build an array of regular expressions of expected errors
const regex = [];
modules.forEach(module => {
variables.forEach(variable => {
if (module.variables.indexOf(variable) === -1) {
// the module doesn't include the env variable, an error is expected when requiring the variable
regex.push([
new RegExp(`(${module.name})`),
new RegExp(`Can't resolve '${variable}'`),
]);
}
});
});
module.exports = regex;