MCPcopy Create free account
hub / github.com/chhoumann/quickadd / executeConditional

Method executeConditional

src/engine/MacroChoiceEngine.ts:710–734  ·  view source on GitHub ↗
(command: IConditionalCommand)

Source from the content-addressed store, hash-verified

708 }
709
710 private async executeConditional(command: IConditionalCommand) {
711 const shouldRunThenBranch = await evaluateCondition(command.condition, {
712 variables: this.params.variables,
713 evaluateScriptCondition: async (condition: ScriptCondition) =>
714 await this.evaluateScriptCondition(condition),
715 });
716
717 const branch = shouldRunThenBranch
718 ? command.thenCommands
719 : command.elseCommands;
720
721 if (!Array.isArray(branch) || branch.length === 0) {
722 return;
723 }
724
725 await this.executeCommands(branch);
726
727 // executeCommands swallows aborts (signals + returns) so the inner branch
728 // loop stops; re-throw the pending abort here so the outer macro loop halts
729 // too instead of running the commands after this conditional.
730 const abort = this.choiceExecutor.consumeAbortSignal?.();
731 if (abort) {
732 throw abort;
733 }
734 }
735
736 public async runSubset(commands: ICommand[]): Promise<void> {
737 if (!commands?.length) return;

Callers 1

executeCommandsMethod · 0.95

Calls 4

executeCommandsMethod · 0.95
evaluateConditionFunction · 0.90
consumeAbortSignalMethod · 0.65

Tested by

no test coverage detected