fix: use module name in logs for plugins loaded with plugins option
This commit is contained in:
@@ -19,6 +19,7 @@ module.exports = (context, pluginsPath) => {
|
||||
if (isPlainObject(plugin)) {
|
||||
Object.entries(plugin).forEach(([type, func]) => {
|
||||
if (PLUGINS_DEFINITIONS[type]) {
|
||||
Reflect.defineProperty(func, 'pluginName', {value: 'Inline plugin', writable: false, enumerable: true});
|
||||
plugins[type] = [...(PLUGINS_DEFINITIONS[type].multiple ? plugins[type] || [] : []), [func, config]];
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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}"`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,8 @@ const validateSingleStep = conf => {
|
||||
return false;
|
||||
}
|
||||
|
||||
const [path, config] = parseConfig(conf[0]);
|
||||
return (isString(path) || isFunction(path)) && isPlainObject(config);
|
||||
const [name, config] = parseConfig(conf[0]);
|
||||
return (isString(name) || isFunction(name)) && isPlainObject(config);
|
||||
};
|
||||
|
||||
const validateMultipleStep = conf => {
|
||||
@@ -45,11 +45,11 @@ function validateStep({multiple, required}, conf) {
|
||||
return conf.length === 0 || (multiple ? validateMultipleStep : validateSingleStep)(conf);
|
||||
}
|
||||
|
||||
function loadPlugin({cwd}, path, pluginsPath) {
|
||||
const basePath = pluginsPath[path]
|
||||
? dirname(resolveFrom.silent(__dirname, pluginsPath[path]) || resolveFrom(cwd, pluginsPath[path]))
|
||||
function loadPlugin({cwd}, name, pluginsPath) {
|
||||
const basePath = pluginsPath[name]
|
||||
? dirname(resolveFrom.silent(__dirname, pluginsPath[name]) || resolveFrom(cwd, pluginsPath[name]))
|
||||
: __dirname;
|
||||
return isFunction(path) ? path : require(resolveFrom.silent(basePath, path) || resolveFrom(cwd, path));
|
||||
return isFunction(name) ? name : require(resolveFrom.silent(basePath, name) || resolveFrom(cwd, name));
|
||||
}
|
||||
|
||||
function parseConfig(plugin) {
|
||||
|
||||
Reference in New Issue
Block a user