@@ -4,8 +4,8 @@ export class UpdatePlatformCommand implements ICommand {
4
4
constructor ( private $options : IOptions ,
5
5
private $projectData : IProjectData ,
6
6
private $platformService : IPlatformService ,
7
- private $errors : IErrors ,
8
- private $platformsData : IPlatformsData ) {
7
+ private $platformEnvironmentRequirements : IPlatformEnvironmentRequirements ,
8
+ private $errors : IErrors ) {
9
9
this . $projectData . initializeProjectData ( ) ;
10
10
}
11
11
@@ -18,12 +18,24 @@ export class UpdatePlatformCommand implements ICommand {
18
18
this . $errors . fail ( "No platform specified. Please specify platforms to update." ) ;
19
19
}
20
20
21
- for ( const arg of args ) {
21
+ _ . each ( args , arg => {
22
22
const platform = arg . split ( "@" ) [ 0 ] ;
23
23
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 ) ;
27
39
}
28
40
29
41
return true ;
0 commit comments