Adrià Vilanova Martínez | ab4c80e | 2024-05-04 19:53:33 +0200 | [diff] [blame] | 1 | import Script from './Script'; |
| 2 | |
Adrià Vilanova Martínez | 8b591d9 | 2024-10-19 15:55:15 +0200 | [diff] [blame] | 3 | export default class LegacyScriptRunner { |
Adrià Vilanova Martínez | ab4c80e | 2024-05-04 19:53:33 +0200 | [diff] [blame] | 4 | private scripts: Script[] = []; |
| 5 | |
| 6 | add(...scripts: Script[]) { |
| 7 | this.scripts.push(...scripts); |
| 8 | } |
| 9 | |
| 10 | run() { |
| 11 | this.scripts.sort((a, b) => { |
| 12 | if (a.priority < b.priority) return -1; |
| 13 | if (a.priority > b.priority) return 1; |
| 14 | return 0; |
| 15 | }); |
| 16 | for (const script of this.scripts) { |
| 17 | script.execute(); |
| 18 | } |
| 19 | } |
| 20 | } |