1
1
import * as path from "path" ;
2
- import { NODE_MODULES_FOLDER_NAME , NativePlatformStatus , PACKAGE_JSON_FILE_NAME , APP_GRADLE_FILE_NAME , BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
2
+ import { NativePlatformStatus , PACKAGE_JSON_FILE_NAME , APP_GRADLE_FILE_NAME , BUILD_XCCONFIG_FILE_NAME } from "../constants" ;
3
3
import { getHash , hook } from "../common/helpers" ;
4
4
import { PrepareData } from "../data/prepare-data" ;
5
5
@@ -37,7 +37,6 @@ export class ProjectChangesService implements IProjectChangesService {
37
37
38
38
private _changesInfo : IProjectChangesInfo ;
39
39
private _prepareInfo : IPrepareInfo ;
40
- private _newFiles : number = 0 ;
41
40
private _outputProjectMtime : number ;
42
41
private _outputProjectCTime : number ;
43
42
@@ -58,8 +57,6 @@ export class ProjectChangesService implements IProjectChangesService {
58
57
this . _changesInfo = new ProjectChangesInfo ( ) ;
59
58
const isNewPrepareInfo = await this . ensurePrepareInfo ( platformData , projectData , prepareData ) ;
60
59
if ( ! isNewPrepareInfo ) {
61
- this . _newFiles = 0 ;
62
-
63
60
this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
64
61
65
62
const platformResourcesDir = path . join ( projectData . appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
@@ -68,10 +65,8 @@ export class ProjectChangesService implements IProjectChangesService {
68
65
this . $nodeModulesDependenciesBuilder . getProductionDependencies ( projectData . projectDir )
69
66
. filter ( dep => dep . nativescript && this . $fs . exists ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ) )
70
67
. map ( dep => {
71
- this . _changesInfo . nativeChanged = this . _changesInfo . nativeChanged || this . containsNewerFiles (
72
- path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ,
73
- projectData ,
74
- this . fileChangeRequiresBuild ) ;
68
+ this . _changesInfo . nativeChanged = this . _changesInfo . nativeChanged ||
69
+ this . containsNewerFiles ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) , projectData ) ;
75
70
} ) ;
76
71
77
72
this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
@@ -220,7 +215,7 @@ export class ProjectChangesService implements IProjectChangesService {
220
215
return false ;
221
216
}
222
217
223
- private containsNewerFiles ( dir : string , projectData : IProjectData , processFunc ?: ( filePath : string , projectData : IProjectData ) => boolean ) : boolean {
218
+ private containsNewerFiles ( dir : string , projectData : IProjectData ) : boolean {
224
219
const dirName = path . basename ( dir ) ;
225
220
this . $logger . trace ( `containsNewerFiles will check ${ dir } ` ) ;
226
221
if ( _ . startsWith ( dirName , '.' ) ) {
@@ -242,23 +237,12 @@ export class ProjectChangesService implements IProjectChangesService {
242
237
const changed = this . isFileModified ( fileStats , filePath ) ;
243
238
244
239
if ( changed ) {
245
- this . $logger . trace ( `File ${ filePath } has been changed.` ) ;
246
- if ( processFunc ) {
247
- this . _newFiles ++ ;
248
- this . $logger . trace ( `Incremented the newFiles counter. Current value is ${ this . _newFiles } ` ) ;
249
- const filePathRelative = path . relative ( projectData . projectDir , filePath ) ;
250
- if ( processFunc . call ( this , filePathRelative , projectData ) ) {
251
- this . $logger . trace ( `containsNewerFiles returns true for ${ dir } . The modified file is ${ filePath } ` ) ;
252
- return true ;
253
- }
254
- } else {
255
- this . $logger . trace ( `containsNewerFiles returns true for ${ dir } . The modified file is ${ filePath } ` ) ;
256
- return true ;
257
- }
240
+ this . $logger . trace ( `containsNewerFiles returns true for ${ dir } . The modified file is ${ filePath } ` ) ;
241
+ return true ;
258
242
}
259
243
260
244
if ( fileStats . isDirectory ( ) ) {
261
- if ( this . containsNewerFiles ( filePath , projectData , processFunc ) ) {
245
+ if ( this . containsNewerFiles ( filePath , projectData ) ) {
262
246
this . $logger . trace ( `containsNewerFiles returns true for ${ dir } .` ) ;
263
247
return true ;
264
248
}
@@ -281,29 +265,5 @@ export class ProjectChangesService implements IProjectChangesService {
281
265
282
266
return changed ;
283
267
}
284
-
285
- private fileChangeRequiresBuild ( file : string , projectData : IProjectData ) {
286
- if ( path . basename ( file ) === PACKAGE_JSON_FILE_NAME ) {
287
- return true ;
288
- }
289
- const projectDir = projectData . projectDir ;
290
- if ( _ . startsWith ( path . join ( projectDir , file ) , projectData . appResourcesDirectoryPath ) ) {
291
- return true ;
292
- }
293
- if ( _ . startsWith ( file , NODE_MODULES_FOLDER_NAME ) ) {
294
- let filePath = file ;
295
- while ( filePath !== NODE_MODULES_FOLDER_NAME ) {
296
- filePath = path . dirname ( filePath ) ;
297
- const fullFilePath = path . join ( projectDir , path . join ( filePath , PACKAGE_JSON_FILE_NAME ) ) ;
298
- if ( this . $fs . exists ( fullFilePath ) ) {
299
- const json = this . $fs . readJson ( fullFilePath ) ;
300
- if ( json [ "nativescript" ] && _ . startsWith ( file , path . join ( filePath , "platforms" ) ) ) {
301
- return true ;
302
- }
303
- }
304
- }
305
- }
306
- return false ;
307
- }
308
268
}
309
269
$injector . register ( "projectChangesService" , ProjectChangesService ) ;
0 commit comments