(command: IConditionalCommand)
| 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; |
no test coverage detected