Add console.log for outputting the path.

feature/esm
SamTV12345 2023-07-22 22:32:44 +02:00
parent a5ce90c135
commit fda3ea4c92
1 changed files with 6 additions and 4 deletions

View File

@ -9,7 +9,7 @@ const disabledHookReasons = {
},
};
const loadFn = (path, hookName) => {
const loadFn = async (path, hookName) => {
let functionName;
const parts = path.split(':');
@ -24,7 +24,9 @@ const loadFn = (path, hookName) => {
functionName = parts[1];
}
let fn = require(path);
console.log(path)
let fn = await import(path);
functionName = functionName ? functionName : hookName;
for (const name of functionName.split('.')) {
@ -33,7 +35,7 @@ const loadFn = (path, hookName) => {
return fn;
};
export const extractHooks = (parts, hookSetName, normalizer) => {
export const extractHooks = async (parts, hookSetName, normalizer) => {
const hooks = {};
for (const part of parts) {
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
@ -53,7 +55,7 @@ export const extractHooks = (parts, hookSetName, normalizer) => {
}
let hookFn;
try {
hookFn = loadFn(hookFnName, hookName);
hookFn = await loadFn(hookFnName, hookName);
if (!hookFn) throw new Error('Not a function');
} catch (err) {
console.error(`Failed to load hook function "${hookFnName}" for plugin "${part.plugin}" ` +