2017-03-16 23:11:02 +08:00
|
|
|
const variables = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg', 'hhh', 'iii'];
|
2017-02-04 22:29:58 +08:00
|
|
|
const modules = [{
|
|
|
|
|
name: 'aaa',
|
|
|
|
|
variables: ['aaa']
|
|
|
|
|
}, {
|
|
|
|
|
name: 'bbbccc',
|
|
|
|
|
variables: ['bbb', 'ccc']
|
|
|
|
|
}, {
|
|
|
|
|
name: 'ddd',
|
|
|
|
|
variables: []
|
2017-02-04 22:48:48 +08:00
|
|
|
}, {
|
|
|
|
|
name: 'eeefff',
|
|
|
|
|
variables: ['eee', 'fff']
|
|
|
|
|
}, {
|
|
|
|
|
name: 'ggghhh',
|
|
|
|
|
variables: ['ggg', 'hhh']
|
2017-03-16 23:11:02 +08:00
|
|
|
}, {
|
|
|
|
|
name: 'iii',
|
|
|
|
|
variables: ['iii']
|
2017-02-04 22:29:58 +08:00
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
// 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;
|