refactor: move classes instantiated at CC start to scripts
Bug: twpowertools:176
Change-Id: I5ac38aa432ee85bd276ee1c867492100d82c1438
diff --git a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts b/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
index d47e947..02ce31e 100644
--- a/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
+++ b/src/common/architecture/entrypoint/EntrypointScriptRunner.ts
@@ -1,19 +1,25 @@
import Features from '../../../features/Features';
+import StandaloneScripts from '../../../scripts/Scripts';
+import ScriptProvider from '../scripts/ScriptProvider';
import ScriptRunner from '../scripts/ScriptRunner';
import { Context } from './Context';
export default class EntrypointScriptRunner {
- private features: Features;
private scriptRunner: ScriptRunner;
constructor(public context: Context) {
- this.features = new Features();
this.scriptRunner = new ScriptRunner();
+ this.addScriptProvider(new Features());
+ this.addScriptProvider(new StandaloneScripts());
+ }
+
+ addScriptProvider(scriptProvider: ScriptProvider): EntrypointScriptRunner {
+ const scripts = scriptProvider.getScripts(this.context);
+ this.scriptRunner.add(...scripts);
+ return this;
}
run() {
- const scripts = this.features.getScripts(this.context);
- this.scriptRunner.add(...scripts);
this.scriptRunner.run();
}
}