mirror of
https://github.com/certd/certd.git
synced 2025-11-25 09:10:11 +08:00
chore: 插件编辑与运行测试beta
This commit is contained in:
@@ -3,14 +3,23 @@ import { AbstractTaskPlugin } from "./api.js";
|
||||
import { pluginGroups } from "./group.js";
|
||||
|
||||
const onRegister = ({ key, value }: OnRegisterContext<AbstractTaskPlugin>) => {
|
||||
//如果有相同名字的先移除
|
||||
|
||||
for (const group of Object.values(pluginGroups)) {
|
||||
const index = group.plugins.findIndex(plugin => plugin.name === key);
|
||||
if (index > -1) {
|
||||
group.plugins.splice(index, 1);
|
||||
}
|
||||
}
|
||||
|
||||
const group = value?.define?.group as string;
|
||||
if (group) {
|
||||
if (pluginGroups.hasOwnProperty(group)) {
|
||||
// @ts-ignore
|
||||
pluginGroups[group].plugins.push(value.define);
|
||||
} else {
|
||||
pluginGroups.other.plugins.push(value.define);
|
||||
return;
|
||||
}
|
||||
}
|
||||
pluginGroups.other.plugins.push(value.define);
|
||||
};
|
||||
export const pluginRegistry = createRegistry<AbstractTaskPlugin>("plugin", onRegister);
|
||||
|
||||
Reference in New Issue
Block a user