Add check for duplicate action registration

- Added a check in the registerAction method to prevent duplicate actions from being registered.
- Removed the line that clears the actions array in the loadCustomActions method.
This commit is contained in:
bobo.yang 2023-08-09 18:36:30 +08:00
parent e0c638e3c0
commit 4c34d06b33

View File

@ -72,6 +72,10 @@ export default class ActionManager {
} }
public registerAction(action: Action): void { public registerAction(action: Action): void {
const existAction = this.actions.find(a => a.name === action.name);
if (existAction) {
return ;
}
this.actions.push(action); this.actions.push(action);
} }
@ -169,7 +173,6 @@ export default class ActionManager {
} }
public loadCustomActions(workflowsDir: string): void { public loadCustomActions(workflowsDir: string): void {
this.actions = [];
const customActionsInstance = CustomActions.getInstance(); const customActionsInstance = CustomActions.getInstance();
customActionsInstance.parseActions(workflowsDir); customActionsInstance.parseActions(workflowsDir);