@@ -46,6 +46,20 @@ export class PlatformService extends EventEmitter implements IPlatformService {
4646 super ( ) ;
4747 }
4848
49+ public async cleanPlatforms ( platforms : string [ ] , platformTemplate : string , projectData : IProjectData , platformSpecificData : IPlatformSpecificData , framworkPath ?: string ) : Promise < void > {
50+ for ( let platform of platforms ) {
51+ let version : string = this . getCurrentPlatformVersion ( platform , projectData ) ;
52+
53+ let platformWithVersion : string = platform ;
54+ if ( version !== undefined ) {
55+ platformWithVersion += "@" + version ;
56+ }
57+
58+ await this . removePlatforms ( [ platform ] , projectData ) ;
59+ await this . addPlatforms ( [ platformWithVersion ] , platformTemplate , projectData , platformSpecificData ) ;
60+ }
61+ }
62+
4963 public async addPlatforms ( platforms : string [ ] , platformTemplate : string , projectData : IProjectData , platformSpecificData : IPlatformSpecificData , frameworkPath ?: string ) : Promise < void > {
5064 let platformsDir = projectData . platformsDir ;
5165 this . $fs . ensureDirectoryExists ( platformsDir ) ;
@@ -55,6 +69,17 @@ export class PlatformService extends EventEmitter implements IPlatformService {
5569 }
5670 }
5771
72+ private getCurrentPlatformVersion ( platform : string , projectData : IProjectData ) : string {
73+ let platformData = this . $platformsData . getPlatformData ( platform , projectData ) ;
74+ let currentPlatformData : any = this . $projectDataService . getNSValue ( projectData . projectDir , platformData . frameworkPackageName ) ;
75+ let version : string ;
76+ if ( currentPlatformData && currentPlatformData [ constants . VERSION_STRING ] ) {
77+ version = currentPlatformData [ constants . VERSION_STRING ] ;
78+ } ;
79+
80+ return version ;
81+ }
82+
5883 private async addPlatform ( platformParam : string , platformTemplate : string , projectData : IProjectData , platformSpecificData : IPlatformSpecificData , frameworkPath ?: string ) : Promise < void > {
5984 let data = platformParam . split ( "@" ) ,
6085 platform = data [ 0 ] . toLowerCase ( ) ,
@@ -69,9 +94,9 @@ export class PlatformService extends EventEmitter implements IPlatformService {
6994 }
7095
7196 let platformData = this . $platformsData . getPlatformData ( platform , projectData ) ;
72- let currentPlatformData : any = this . $projectDataService . getNSValue ( projectData . projectDir , platformData . frameworkPackageName ) ;
73- if ( currentPlatformData && currentPlatformData [ constants . VERSION_STRING ] ) {
74- version = currentPlatformData [ constants . VERSION_STRING ] ;
97+
98+ if ( version === undefined ) {
99+ version = this . getCurrentPlatformVersion ( platform , projectData ) ;
75100 }
76101
77102 // Copy platform specific files in platforms dir
0 commit comments