mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-25 09:56:15 -04:00
Add console.log for outputting the path.
This commit is contained in:
parent
a5ce90c135
commit
fda3ea4c92
1 changed files with 6 additions and 4 deletions
|
@ -9,7 +9,7 @@ const disabledHookReasons = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadFn = (path, hookName) => {
|
const loadFn = async (path, hookName) => {
|
||||||
let functionName;
|
let functionName;
|
||||||
const parts = path.split(':');
|
const parts = path.split(':');
|
||||||
|
|
||||||
|
@ -24,7 +24,9 @@ const loadFn = (path, hookName) => {
|
||||||
functionName = parts[1];
|
functionName = parts[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
let fn = require(path);
|
console.log(path)
|
||||||
|
|
||||||
|
let fn = await import(path);
|
||||||
functionName = functionName ? functionName : hookName;
|
functionName = functionName ? functionName : hookName;
|
||||||
|
|
||||||
for (const name of functionName.split('.')) {
|
for (const name of functionName.split('.')) {
|
||||||
|
@ -33,7 +35,7 @@ const loadFn = (path, hookName) => {
|
||||||
return fn;
|
return fn;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const extractHooks = (parts, hookSetName, normalizer) => {
|
export const extractHooks = async (parts, hookSetName, normalizer) => {
|
||||||
const hooks = {};
|
const hooks = {};
|
||||||
for (const part of parts) {
|
for (const part of parts) {
|
||||||
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
|
for (const [hookName, regHookFnName] of Object.entries(part[hookSetName] || {})) {
|
||||||
|
@ -53,7 +55,7 @@ export const extractHooks = (parts, hookSetName, normalizer) => {
|
||||||
}
|
}
|
||||||
let hookFn;
|
let hookFn;
|
||||||
try {
|
try {
|
||||||
hookFn = loadFn(hookFnName, hookName);
|
hookFn = await loadFn(hookFnName, hookName);
|
||||||
if (!hookFn) throw new Error('Not a function');
|
if (!hookFn) throw new Error('Not a function');
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(`Failed to load hook function "${hookFnName}" for plugin "${part.plugin}" ` +
|
console.error(`Failed to load hook function "${hookFnName}" for plugin "${part.plugin}" ` +
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue