@@ -4,24 +4,28 @@ import { cache } from "../common/decorators";
44export 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