feat: Expect plugins to return Promises
BREAKING CHANGE: Each plugin is expected to return an async function or a Promise returning function. The callback parameter is not passed to plugins anymore.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const {promisify, inspect} = require('util');
|
||||
const {inspect} = require('util');
|
||||
const {isString, isObject, isFunction, noop, cloneDeep} = require('lodash');
|
||||
const importFrom = require('import-from');
|
||||
|
||||
@@ -14,9 +14,9 @@ module.exports = (pluginType, pluginConfig, logger, validator) => {
|
||||
|
||||
let func;
|
||||
if (isFunction(plugin)) {
|
||||
func = promisify(plugin.bind(null, cloneDeep(config)));
|
||||
func = plugin.bind(null, cloneDeep(config));
|
||||
} else if (isObject(plugin) && plugin[pluginType] && isFunction(plugin[pluginType])) {
|
||||
func = promisify(plugin[pluginType].bind(null, cloneDeep(config)));
|
||||
func = plugin[pluginType].bind(null, cloneDeep(config));
|
||||
} else {
|
||||
throw new Error(
|
||||
`The ${pluginType} plugin must be a function, or an object with a function in the property ${pluginType}.`
|
||||
|
||||
Reference in New Issue
Block a user