Skip to content

Commit

Permalink
Update lifecycle.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jhildenbiddle committed Feb 3, 2022
1 parent cfbcd81 commit 67c5410
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/core/init/lifecycle.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,26 @@ export function Lifecycle(Base) {
if (index >= queue.length) {
next(data);
} else if (typeof hookFn === 'function') {
const errTitle = `Docsify plugin ${
hookFn.name ? '"' + hookFn.name + '"' : ''
} error (${hookName})`;
const errTitle = `Docsify plugin error (${hookName})`;

if (hookFn.length === 2) {
try {
hookFn(data, result => {
data = result;
step(index + 1);
});
} catch (err) {
console.error(errTitle, err);
}
step(index + 1);
} else {
let result;

try {
result = hookFn(data);
const result = hookFn(data);

data = result === undefined ? data : data;
} catch (err) {
console.error(errTitle, err);
}

data = result || data;
step(index + 1);
}
} else {
Expand Down

0 comments on commit 67c5410

Please sign in to comment.