Fix async issue in plugin addition

This commit is contained in:
Harvey Zack committed 2023-11-24 10:00:49 +08:00
1 parent d579e7e86d
commit 21a735f86b
7 files changed
+165 -111

No files matched your search

+2 -2
View File
@@ -37,9 +37,9 @@ export default class Plugins {
}
}
add(plugin) {
async add(plugin) {
this.id += 1;
const result = plugin.call(this.art, this.art);
const result = await plugin.call(this.art, this.art);
const pluginName = (result && result.name) || plugin.name || `plugin${this.id}`;
errorHandle(!has(this, pluginName), `Cannot add a plugin that already has the same name: ${pluginName}`);
def(this, pluginName, {