@@ -464,16 +464,36 @@ export class PlatformService implements IPlatformService {
464464 private updatePlatformCore ( platformData : IPlatformData , currentVersion : string , newVersion : string ) : IFuture < void > {
465465 return ( ( ) => {
466466 // Remove old framework files
467- var oldFrameworkFiles = this . getFrameworkFiles ( platformData , currentVersion ) . wait ( ) ;
468- _ . each ( oldFrameworkFiles , file => {
469- this . $fs . deleteFile ( path . join ( platformData . projectRoot , file ) ) . wait ( ) ;
467+ var oldFrameworkData = this . getFrameworkFiles ( platformData , currentVersion ) . wait ( ) ;
468+
469+ _ . each ( oldFrameworkData . frameworkFiles , file => {
470+ var fileToDelete = path . join ( platformData . projectRoot , file ) ;
471+ this . $logger . trace ( "Deleting %s" , fileToDelete ) ;
472+ this . $fs . deleteFile ( fileToDelete ) . wait ( ) ;
473+ } ) ;
474+
475+ _ . each ( oldFrameworkData . frameworkDirectories , dir => {
476+ var dirToDelete = path . join ( platformData . projectRoot , dir ) ;
477+ this . $logger . trace ( "Deleting %s" , dirToDelete ) ;
478+ this . $fs . deleteDirectory ( dirToDelete ) . wait ( ) ;
470479 } ) ;
471480
472481 // Add new framework files
473- var newFrameworkFiles = this . getFrameworkFiles ( platformData , newVersion ) . wait ( ) ;
482+ var newFrameworkData = this . getFrameworkFiles ( platformData , newVersion ) . wait ( ) ;
474483 var cacheDirectoryPath = this . getNpmCacheDirectoryCore ( platformData . frameworkPackageName , newVersion ) ;
475- _ . each ( newFrameworkFiles , file => {
476- shell . cp ( "-f" , path . join ( cacheDirectoryPath , file ) , path . join ( platformData . projectRoot , file ) ) ;
484+
485+ _ . each ( newFrameworkData . frameworkFiles , file => {
486+ var sourceFile = path . join ( cacheDirectoryPath , constants . PROJECT_FRAMEWORK_FOLDER_NAME , file ) ;
487+ var destinationFile = path . join ( platformData . projectRoot , file ) ;
488+ this . $logger . trace ( "Replacing %s with %s" , sourceFile , destinationFile ) ;
489+ shell . cp ( "-f" , sourceFile , destinationFile ) ;
490+ } ) ;
491+
492+ _ . each ( newFrameworkData . frameworkDirectories , dir => {
493+ var sourceDirectory = path . join ( cacheDirectoryPath , constants . PROJECT_FRAMEWORK_FOLDER_NAME , dir ) ;
494+ var destinationDirectory = path . join ( platformData . projectRoot , dir ) ;
495+ this . $logger . trace ( "Copying %s to %s" , sourceDirectory , destinationDirectory ) ;
496+ shell . cp ( "-fR" , path . join ( sourceDirectory , "*" ) , destinationDirectory ) ;
477497 } ) ;
478498
479499 // Update .tnsproject file
@@ -485,16 +505,22 @@ export class PlatformService implements IPlatformService {
485505 } ) . future < void > ( ) ( ) ;
486506 }
487507
488- private getFrameworkFiles ( platformData : IPlatformData , version : string ) : IFuture < string [ ] > {
508+ private getFrameworkFiles ( platformData : IPlatformData , version : string ) : IFuture < any > {
489509 return ( ( ) => {
490510 var npmCacheDirectoryPath = this . getNpmCacheDirectory ( platformData . frameworkPackageName , version ) . wait ( ) ;
511+
491512 var allFiles = this . $fs . enumerateFilesInDirectorySync ( npmCacheDirectoryPath ) ;
492513 var filteredFiles = _ . filter ( allFiles , file => _ . contains ( platformData . frameworkFilesExtensions , path . extname ( file ) ) ) ;
493- var relativeToCacheFiles = _ . map ( filteredFiles , file => file . substr ( npmCacheDirectoryPath . length ) ) ;
494514
495- return relativeToCacheFiles ;
515+ var allFrameworkDirectories = _ . map ( this . $fs . readDirectory ( path . join ( npmCacheDirectoryPath , constants . PROJECT_FRAMEWORK_FOLDER_NAME ) ) . wait ( ) , dir => path . join ( npmCacheDirectoryPath , constants . PROJECT_FRAMEWORK_FOLDER_NAME , dir ) ) ;
516+ var filteredFrameworkDirectories = _ . filter ( allFrameworkDirectories , dir => this . $fs . getFsStats ( dir ) . wait ( ) . isDirectory ( ) && ( _ . contains ( platformData . frameworkFilesExtensions , path . extname ( dir ) ) || _ . contains ( platformData . frameworkDirectoriesNames , path . basename ( dir ) ) ) ) ;
496517
497- } ) . future < string [ ] > ( ) ( ) ;
518+ return {
519+ frameworkFiles : this . mapFrameworkFiles ( npmCacheDirectoryPath , filteredFiles ) ,
520+ frameworkDirectories : this . mapFrameworkFiles ( npmCacheDirectoryPath , filteredFrameworkDirectories )
521+ }
522+
523+ } ) . future < any > ( ) ( ) ;
498524 }
499525
500526 private getNpmCacheDirectory ( packageName : string , version : string ) : IFuture < string > {
@@ -512,5 +538,9 @@ export class PlatformService implements IPlatformService {
512538 private getNpmCacheDirectoryCore ( packageName : string , version : string ) : string {
513539 return path . join ( this . $npm . getCacheRootPath ( ) , packageName , version , "package" ) ;
514540 }
541+
542+ private mapFrameworkFiles ( npmCacheDirectoryPath : string , files : string [ ] ) : string [ ] {
543+ return _ . map ( files , file => file . substr ( npmCacheDirectoryPath . length + constants . PROJECT_FRAMEWORK_FOLDER_NAME . length + 1 ) )
544+ }
515545}
516546$injector . register ( "platformService" , PlatformService ) ;
0 commit comments