Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this.pluginDescriptors.forEach(pluginExpression => {
if (typeof pluginExpression === 'string') {
if (pluginExpression.includes('*')) {
// Plugin directory is the node_modules folder of the module that installed stryker
// So if current __dirname is './@stryker-mutator/core/src/di' so 4 directories above
const pluginDirectory = path.dirname(path.resolve(__dirname, '..', '..', '..', '..', pluginExpression));
const regexp = new RegExp('^' + path.basename(pluginExpression).replace('*', '.*'));
this.log.debug('Loading %s from %s', pluginExpression, pluginDirectory);
const plugins = fsAsPromised
.readdirSync(pluginDirectory)
.filter(pluginName => !IGNORED_PACKAGES.includes(pluginName) && regexp.test(pluginName))
.map(pluginName => path.resolve(pluginDirectory, pluginName));
if (plugins.length === 0) {
this.log.debug('Expression %s not resulted in plugins to load', pluginExpression);
}
plugins
.map(plugin => {
this.log.debug('Loading plugin "%s" (matched with expression %s)', plugin, pluginExpression);
return plugin;
})
.forEach(p => modules.push(p));
} else {
modules.push(pluginExpression);
}
} else {
this.pluginDescriptors.forEach(pluginExpression => {
if (_.isString(pluginExpression)) {
if (pluginExpression.indexOf('*') !== -1) {
// Plugin directory is the node_modules folder of the module that installed stryker
// So if current __dirname is './stryker/src/di' so 3 directories above
const pluginDirectory = path.resolve(__dirname, '..', '..', '..');
const regexp = new RegExp('^' + pluginExpression.replace('*', '.*'));
this.log.debug('Loading %s from %s', pluginExpression, pluginDirectory);
const plugins = fsAsPromised.readdirSync(pluginDirectory)
.filter(pluginName => IGNORED_PACKAGES.indexOf(pluginName) === -1 && regexp.test(pluginName))
.map(pluginName => pluginDirectory + '/' + pluginName);
if (plugins.length === 0) {
this.log.debug('Expression %s not resulted in plugins to load', pluginExpression);
}
plugins
.map(plugin => path.basename(plugin))
.map(plugin => {
this.log.debug('Loading plugins %s (matched with expression %s)', plugin, pluginExpression);
return plugin;
})
.forEach(p => modules.push(p));
} else {
modules.push(pluginExpression);
}
} else {