fix: use module name in logs for plugins loaded with plugins option

This commit is contained in:
Pierre Vanduynslager
2018-10-09 15:29:04 -04:00
parent 3e8216ab35
commit ff275a5cd4
4 changed files with 15 additions and 14 deletions
+6 -6
View File
@@ -10,9 +10,9 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
return noop;
}
const [path, config] = parseConfig(pluginOpt);
const pluginName = isFunction(path) ? `[Function: ${path.name}]` : path;
const plugin = loadPlugin(context, path, pluginsPath);
const [name, config] = parseConfig(pluginOpt);
const pluginName = name.pluginName ? name.pluginName : isFunction(name) ? `[Function: ${name.name}]` : name;
const plugin = loadPlugin(context, name, pluginsPath);
let func;
if (isFunction(plugin)) {
@@ -48,10 +48,10 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
Reflect.defineProperty(validator, 'pluginName', {value: pluginName, writable: false, enumerable: true});
if (!isFunction(pluginOpt)) {
if (pluginsPath[path]) {
logger.success(`Loaded plugin "${type}" from "${path}" in shareable config "${pluginsPath[path]}"`);
if (pluginsPath[name]) {
logger.success(`Loaded plugin "${type}" from "${pluginName}" in shareable config "${pluginsPath[name]}"`);
} else {
logger.success(`Loaded plugin "${type}" from "${path}"`);
logger.success(`Loaded plugin "${type}" from "${pluginName}"`);
}
}