Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 1 | import Features from '../../../features/Features'; |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 2 | import StandaloneScripts from '../../../scripts/Scripts'; |
| 3 | import ScriptProvider from '../scripts/ScriptProvider'; |
Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 4 | import ScriptRunner from '../scripts/ScriptRunner'; |
| 5 | import { Context } from './Context'; |
| 6 | |
| 7 | export default class EntrypointScriptRunner { |
Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 8 | private scriptRunner: ScriptRunner; |
| 9 | |
| 10 | constructor(public context: Context) { |
Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 11 | this.scriptRunner = new ScriptRunner(); |
Adrià Vilanova Martínez | 2ba5d8d | 2024-05-04 21:17:16 +0200 | [diff] [blame] | 12 | this.addScriptProvider(new Features()); |
| 13 | this.addScriptProvider(new StandaloneScripts()); |
| 14 | } |
| 15 | |
| 16 | addScriptProvider(scriptProvider: ScriptProvider): EntrypointScriptRunner { |
| 17 | const scripts = scriptProvider.getScripts(this.context); |
| 18 | this.scriptRunner.add(...scripts); |
| 19 | return this; |
Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | run() { |
Adrià Vilanova Martínez | 104f8ef | 2024-05-04 17:22:11 +0200 | [diff] [blame] | 23 | this.scriptRunner.run(); |
| 24 | } |
| 25 | } |