Skip to content

Commit aaac12f

Browse files
committed
fix: remove getDependenciesVersions method from test-initialization-service
1 parent ca3c0e2 commit aaac12f

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

lib/commands/test-init.ts

+1-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,7 @@ class TestInitCommand implements ICommand {
3333

3434
let modulesToInstall: IDependencyInformation[] = [];
3535
try {
36-
const dependencies = this.$testInitializationService.getDependencies(frameworkToInstall);
37-
const dependenciesVersions = this.$testInitializationService.getDependenciesVersions();
38-
modulesToInstall = dependencies.map(dependency => {
39-
dependency.version = dependenciesVersions[dependency.name];
40-
if (!dependency.version) {
41-
this.$errors.failWithoutHelp(`'${dependency}' is not a registered dependency.`);
42-
}
43-
return dependency;
44-
});
36+
modulesToInstall = this.$testInitializationService.getDependencies(frameworkToInstall);
4537
} catch (err) {
4638
this.$errors.failWithoutHelp(`Unable to install the unit testing dependencies. Error: '${err.message}'`);
4739
}

lib/definitions/project.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,6 @@ interface ITestExecutionService {
483483

484484
interface ITestInitializationService {
485485
getDependencies(framework: string): IDependencyInformation[];
486-
getDependenciesVersions(): IDictionary<string>;
487486
}
488487

489488
/**

lib/services/test-initialization-service.ts

+14-10
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,28 @@ import { cache } from "../common/decorators";
44
export class TestInitializationService implements ITestInitializationService {
55
private configsPath = path.join(__dirname, "..", "..", "config");
66

7-
constructor(private $fs: IFileSystem) { }
7+
constructor(private $errors: IErrors,
8+
private $fs: IFileSystem) { }
89

910
@cache()
1011
public getDependencies(selectedFramework: string): IDependencyInformation[] {
1112
const dependenciesPath = path.join(this.configsPath, "test-dependencies.json");
12-
const allDependencies: { name: string, framework: string }[] = this.$fs.readJson(dependenciesPath);
13-
const targetFrameworkDependencies: IDependencyInformation[] = allDependencies
14-
.filter(dependency => !dependency.framework || dependency.framework === selectedFramework);
15-
16-
return targetFrameworkDependencies;
17-
}
13+
const allDependencies: { name: string, framework?: string, excludedPeerDependencies?: string[] }[] = this.$fs.readJson(dependenciesPath);
1814

19-
@cache()
20-
public getDependenciesVersions(): IDictionary<string> {
2115
const dependenciesVersionsPath = path.join(this.configsPath, "test-deps-versions-generated.json");
2216
const dependenciesVersions = this.$fs.readJson(dependenciesVersionsPath);
2317

24-
return dependenciesVersions;
18+
const targetFrameworkDependencies: IDependencyInformation[] = allDependencies
19+
.filter(dependency => !dependency.framework || dependency.framework === selectedFramework)
20+
.map(dependency => {
21+
const dependencyVersion = dependenciesVersions[dependency.name];
22+
if (!dependencyVersion) {
23+
this.$errors.failWithoutHelp(`'${dependency}' is not a registered dependency.`);
24+
}
25+
return { ...dependency, version: dependencyVersion };
26+
});
27+
28+
return targetFrameworkDependencies;
2529
}
2630
}
2731

0 commit comments

Comments
 (0)