@@ -47,7 +47,8 @@ export class ProjectChangesService implements IProjectChangesService {
47
47
private $devicePlatformsConstants : Mobile . IDevicePlatformsConstants ,
48
48
private $fs : IFileSystem ,
49
49
private $logger : ILogger ,
50
- public $hooksService : IHooksService ) {
50
+ public $hooksService : IHooksService ,
51
+ private $nodeModulesDependenciesBuilder : INodeModulesDependenciesBuilder ) {
51
52
}
52
53
53
54
public get currentChanges ( ) : IProjectChangesInfo {
@@ -64,13 +65,16 @@ export class ProjectChangesService implements IProjectChangesService {
64
65
this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
65
66
66
67
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
+ } ) ;
74
78
75
79
this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
76
80
@@ -229,7 +233,7 @@ export class ProjectChangesService implements IProjectChangesService {
229
233
return false ;
230
234
}
231
235
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 {
233
237
const dirName = path . basename ( dir ) ;
234
238
this . $logger . trace ( `containsNewerFiles will check ${ dir } ` ) ;
235
239
if ( _ . startsWith ( dirName , '.' ) ) {
@@ -246,9 +250,6 @@ export class ProjectChangesService implements IProjectChangesService {
246
250
const files = this . $fs . readDirectory ( dir ) ;
247
251
for ( const file of files ) {
248
252
const filePath = path . join ( dir , file ) ;
249
- if ( filePath === skipDir ) {
250
- continue ;
251
- }
252
253
253
254
const fileStats = this . $fs . getFsStats ( filePath ) ;
254
255
const changed = this . isFileModified ( fileStats , filePath ) ;
@@ -270,7 +271,7 @@ export class ProjectChangesService implements IProjectChangesService {
270
271
}
271
272
272
273
if ( fileStats . isDirectory ( ) ) {
273
- if ( this . containsNewerFiles ( filePath , skipDir , projectData , processFunc ) ) {
274
+ if ( this . containsNewerFiles ( filePath , projectData , processFunc ) ) {
274
275
this . $logger . trace ( `containsNewerFiles returns true for ${ dir } .` ) ;
275
276
return true ;
276
277
}
0 commit comments