Skip to content

Commit

Permalink
See #58. Fix newspaper-order linting rule
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavin001 committed Apr 10, 2018
1 parent 15c234c commit 39ba140
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/DependencyManager/DependencyManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// tslint:disable:newspaper-order
// tslint:disable:no-reserved-keywords
import { DependencyFactory } from "./DependencyFactory";
import {
Expand All @@ -22,6 +21,14 @@ export class DependencyManager {
this.initializeDependencies();
}

public load(): Promise<boolean> {
return Promise.all(
this.dependencyDefinitions
.map(def => this.get(def.name))
.map(dep => dep.load())
).then(() => true);
}

private initializeDependencies(): void {
const lookup = DependencyManager.registry;
const beautifierLookup = lookup[this.beautifierName] || {};
Expand All @@ -38,22 +45,10 @@ export class DependencyManager {
});
}

private optionsForDependency(dependencyName: string): DependencyOptions {
return this.options[dependencyName];
}

public has(name: string): boolean {
return Boolean(this.get(name));
}

public load(): Promise<boolean> {
return Promise.all(
this.dependencyDefinitions
.map(def => this.get(def.name))
.map(dep => dep.load())
).then(() => true);
}

public get<T extends Dependency>(dependencyName: string): T {
const options = this.optionsForDependency(dependencyName);
const optionsKey = this.keyForOptions(options);
Expand All @@ -65,6 +60,10 @@ export class DependencyManager {
return dep;
}

private optionsForDependency(dependencyName: string): DependencyOptions {
return this.options[dependencyName];
}

protected get registry(): DependencyRegistry[string] {
return DependencyManager.registry[this.beautifierName];
}
Expand Down

0 comments on commit 39ba140

Please sign in to comment.