( condition: ScriptCondition )
| 780 | } |
| 781 | |
| 782 | private async loadConditionalScript( |
| 783 | condition: ScriptCondition |
| 784 | ): Promise<ConditionalScriptRunner | undefined> { |
| 785 | try { |
| 786 | const script = await getUserScript( |
| 787 | this.buildConditionalUserScript(condition), |
| 788 | this.app |
| 789 | ); |
| 790 | |
| 791 | if (script === undefined || script === null) { |
| 792 | return undefined; |
| 793 | } |
| 794 | |
| 795 | if (typeof script === "function") { |
| 796 | return async () => await script(this.params); |
| 797 | } |
| 798 | |
| 799 | return async () => script; |
| 800 | } catch (error) { |
| 801 | reportError( |
| 802 | error, |
| 803 | `Failed to load conditional script '${condition.scriptPath}'.` |
| 804 | ); |
| 805 | throw error; |
| 806 | } |
| 807 | } |
| 808 | |
| 809 | private buildConditionalUserScript( |
| 810 | condition: ScriptCondition |
no test coverage detected