refactor(plugins): switched from require to await import() when loading plugins (#2558)

This commit is contained in:
Matt Travi
2022-09-17 14:10:05 -07:00
committed by GitHub
parent 466898b3b4
commit 4cd3641dbf
7 changed files with 98 additions and 83 deletions
+2 -2
View File
@@ -5,7 +5,7 @@ const {extractErrors} = require('../utils');
const PLUGINS_DEFINITIONS = require('../definitions/plugins');
const {loadPlugin, parseConfig} = require('./utils');
module.exports = (context, type, pluginOpt, pluginsPath) => {
module.exports = async (context, type, pluginOpt, pluginsPath) => {
const {stdout, stderr, options, logger} = context;
if (!pluginOpt) {
return noop;
@@ -13,7 +13,7 @@ module.exports = (context, type, pluginOpt, pluginsPath) => {
const [name, config] = parseConfig(pluginOpt);
const pluginName = name.pluginName ? name.pluginName : isFunction(name) ? `[Function: ${name.name}]` : name;
const plugin = loadPlugin(context, name, pluginsPath);
const plugin = await loadPlugin(context, name, pluginsPath);
debug(`options for ${pluginName}/${type}: %O`, config);