@@ -4,24 +4,28 @@ import { cache } from "../common/decorators";
4
4
export class TestInitializationService implements ITestInitializationService {
5
5
private configsPath = path . join ( __dirname , ".." , ".." , "config" ) ;
6
6
7
- constructor ( private $fs : IFileSystem ) { }
7
+ constructor ( private $errors : IErrors ,
8
+ private $fs : IFileSystem ) { }
8
9
9
10
@cache ( )
10
11
public getDependencies ( selectedFramework : string ) : IDependencyInformation [ ] {
11
12
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 ) ;
18
14
19
- @cache ( )
20
- public getDependenciesVersions ( ) : IDictionary < string > {
21
15
const dependenciesVersionsPath = path . join ( this . configsPath , "test-deps-versions-generated.json" ) ;
22
16
const dependenciesVersions = this . $fs . readJson ( dependenciesVersionsPath ) ;
23
17
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 ;
25
29
}
26
30
}
27
31
0 commit comments