@@ -47,7 +47,8 @@ export class ProjectChangesService implements IProjectChangesService {
4747 private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
4848 private $fs : IFileSystem ,
4949 private $logger : ILogger ,
50- public $hooksService : IHooksService ) {
50+ public $hooksService : IHooksService ,
51+ private $nodeModulesDependenciesBuilder : INodeModulesDependenciesBuilder ) {
5152 }
5253
5354 public get currentChanges ( ) : IProjectChangesInfo {
@@ -64,13 +65,16 @@ export class ProjectChangesService implements IProjectChangesService {
6465 this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
6566
6667 const platformResourcesDir = path . join ( projectData . appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
67- this . _changesInfo . appResourcesChanged = this . containsNewerFiles ( platformResourcesDir , null , projectData ) ;
68- /*done because currently all node_modules are traversed, a possible improvement could be traversing only the production dependencies*/
69- this . _changesInfo . nativeChanged = this . containsNewerFiles (
70- path . join ( projectData . projectDir , NODE_MODULES_FOLDER_NAME ) ,
71- path . join ( projectData . projectDir , NODE_MODULES_FOLDER_NAME , "tns-ios-inspector" ) ,
72- projectData ,
73- this . fileChangeRequiresBuild ) ;
68+ this . _changesInfo . appResourcesChanged = this . containsNewerFiles ( platformResourcesDir , projectData ) ;
69+
70+ this . $nodeModulesDependenciesBuilder . getProductionDependencies ( projectData . projectDir )
71+ . filter ( dep => dep . nativescript && this . $fs . exists ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ) )
72+ . map ( dep => {
73+ this . _changesInfo . nativeChanged = this . containsNewerFiles (
74+ path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ,
75+ projectData ,
76+ this . fileChangeRequiresBuild ) ;
77+ } ) ;
7478
7579 this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
7680
@@ -229,7 +233,7 @@ export class ProjectChangesService implements IProjectChangesService {
229233 return false ;
230234 }
231235
232- private containsNewerFiles ( dir : string , skipDir : string , projectData : IProjectData , processFunc ?: ( filePath : string , projectData : IProjectData ) => boolean ) : boolean {
236+ private containsNewerFiles ( dir : string , projectData : IProjectData , processFunc ?: ( filePath : string , projectData : IProjectData ) => boolean ) : boolean {
233237 const dirName = path . basename ( dir ) ;
234238 this . $logger . trace ( `containsNewerFiles will check ${ dir } ` ) ;
235239 if ( _ . startsWith ( dirName , '.' ) ) {
@@ -246,9 +250,6 @@ export class ProjectChangesService implements IProjectChangesService {
246250 const files = this . $fs . readDirectory ( dir ) ;
247251 for ( const file of files ) {
248252 const filePath = path . join ( dir , file ) ;
249- if ( filePath === skipDir ) {
250- continue ;
251- }
252253
253254 const fileStats = this . $fs . getFsStats ( filePath ) ;
254255 const changed = this . isFileModified ( fileStats , filePath ) ;
@@ -270,7 +271,7 @@ export class ProjectChangesService implements IProjectChangesService {
270271 }
271272
272273 if ( fileStats . isDirectory ( ) ) {
273- if ( this . containsNewerFiles ( filePath , skipDir , projectData , processFunc ) ) {
274+ if ( this . containsNewerFiles ( filePath , projectData , processFunc ) ) {
274275 this . $logger . trace ( `containsNewerFiles returns true for ${ dir } .` ) ;
275276 return true ;
276277 }
0 commit comments