-
-
Notifications
You must be signed in to change notification settings - Fork 197
/
Copy pathtest-initialization-service.ts
32 lines (25 loc) · 1.33 KB
/
test-initialization-service.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import * as path from "path";
import { cache } from "../common/decorators";
export class TestInitializationService implements ITestInitializationService {
private configsPath = path.join(__dirname, "..", "..", "config");
constructor(private $errors: IErrors,
private $fs: IFileSystem) { }
@cache()
public getDependencies(selectedFramework: string): IDependencyInformation[] {
const dependenciesPath = path.join(this.configsPath, "test-dependencies.json");
const allDependencies: { name: string, framework?: string, excludedPeerDependencies?: string[] }[] = this.$fs.readJson(dependenciesPath);
const dependenciesVersionsPath = path.join(this.configsPath, "test-deps-versions-generated.json");
const dependenciesVersions = this.$fs.readJson(dependenciesVersionsPath);
const targetFrameworkDependencies: IDependencyInformation[] = allDependencies
.filter(dependency => !dependency.framework || dependency.framework === selectedFramework)
.map(dependency => {
const dependencyVersion = dependenciesVersions[dependency.name];
if (!dependencyVersion) {
this.$errors.failWithoutHelp(`'${dependency}' is not a registered dependency.`);
}
return { ...dependency, version: dependencyVersion };
});
return targetFrameworkDependencies;
}
}
$injector.register("testInitializationService", TestInitializationService);