Add more valid

This commit is contained in:
Harvey committed 2021-12-10 11:05:44 +08:00
1 parent 5f45ad112f
commit d919471838
7 files changed
+31 -11

No files matched your search

+1
View File
@@ -34,6 +34,7 @@ export default class Plugins {
add(plugin) {
this.id += 1;
errorHandle(typeof plugin === 'function', `The Plugins.add() first parameter is not a function`);
const result = plugin.call(this, 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}`);