chore(architecture): deprecate some of the new architecture
In order to use Dependency Injection, we need to deprecate old classes
which aren't suitable for it, and which will be replaced by other ones
in followup commits.
Bug: twpowertools:226
Change-Id: I232bd9f036b6fb540eba27d7586d8054ce3de789
diff --git a/src/common/architecture/scripts/LegacyScriptRunner.ts b/src/common/architecture/scripts/LegacyScriptRunner.ts
new file mode 100644
index 0000000..f7b3e82
--- /dev/null
+++ b/src/common/architecture/scripts/LegacyScriptRunner.ts
@@ -0,0 +1,20 @@
+import Script from './Script';
+
+export default class LegacyScriptRunner {
+ private scripts: Script[] = [];
+
+ add(...scripts: Script[]) {
+ this.scripts.push(...scripts);
+ }
+
+ run() {
+ this.scripts.sort((a, b) => {
+ if (a.priority < b.priority) return -1;
+ if (a.priority > b.priority) return 1;
+ return 0;
+ });
+ for (const script of this.scripts) {
+ script.execute();
+ }
+ }
+}