@@ -4,8 +4,8 @@ export class UpdatePlatformCommand implements ICommand {
44 constructor ( private $options : IOptions ,
55 private $projectData : IProjectData ,
66 private $platformService : IPlatformService ,
7- private $errors : IErrors ,
8- private $platformsData : IPlatformsData ) {
7+ private $platformEnvironmentRequirements : IPlatformEnvironmentRequirements ,
8+ private $errors : IErrors ) {
99 this . $projectData . initializeProjectData ( ) ;
1010 }
1111
@@ -18,12 +18,24 @@ export class UpdatePlatformCommand implements ICommand {
1818 this . $errors . fail ( "No platform specified. Please specify platforms to update." ) ;
1919 }
2020
21- for ( const arg of args ) {
21+ _ . each ( args , arg => {
2222 const platform = arg . split ( "@" ) [ 0 ] ;
2323 this . $platformService . validatePlatform ( platform , this . $projectData ) ;
24- const platformData = this . $platformsData . getPlatformData ( platform , this . $projectData ) ;
25- const platformProjectService = platformData . platformProjectService ;
26- await platformProjectService . validate ( this . $projectData ) ;
24+ } ) ;
25+
26+ for ( const arg of args ) {
27+ const [ platform , versionToBeInstalled ] = arg . split ( "@" ) ;
28+ this . $platformService . validatePlatformInstalled ( platform , this . $projectData ) ;
29+ const argsToCheckEnvironmentRequirements : string [ ] = [ platform ] ;
30+ // If version is not specified, we know the command will install the latest compatible Android runtime.
31+ // The latest compatible Android runtime supports Java version, so we do not need to pass it here.
32+ // Passing projectDir to the nativescript-doctor validation will cause it to check the runtime from the current package.json
33+ // So in this case, where we do not want to validate the runtime, just do not pass both projectDir and runtimeVersion.
34+ if ( versionToBeInstalled ) {
35+ argsToCheckEnvironmentRequirements . push ( this . $projectData . projectDir , versionToBeInstalled ) ;
36+ }
37+
38+ await this . $platformEnvironmentRequirements . checkEnvironmentRequirements ( ...argsToCheckEnvironmentRequirements ) ;
2739 }
2840
2941 return true ;
0 commit comments