11import * 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" ;
33import { getHash , hook } from "../common/helpers" ;
44import { PrepareData } from "../data/prepare-data" ;
55
@@ -37,7 +37,6 @@ export class ProjectChangesService implements IProjectChangesService {
3737
3838 private _changesInfo : IProjectChangesInfo ;
3939 private _prepareInfo : IPrepareInfo ;
40- private _newFiles : number = 0 ;
4140 private _outputProjectMtime : number ;
4241 private _outputProjectCTime : number ;
4342
@@ -58,8 +57,6 @@ export class ProjectChangesService implements IProjectChangesService {
5857 this . _changesInfo = new ProjectChangesInfo ( ) ;
5958 const isNewPrepareInfo = await this . ensurePrepareInfo ( platformData , projectData , prepareData ) ;
6059 if ( ! isNewPrepareInfo ) {
61- this . _newFiles = 0 ;
62-
6360 this . _changesInfo . packageChanged = this . isProjectFileChanged ( projectData . projectDir , platformData ) ;
6461
6562 const platformResourcesDir = path . join ( projectData . appResourcesDirectoryPath , platformData . normalizedPlatformName ) ;
@@ -68,10 +65,8 @@ export class ProjectChangesService implements IProjectChangesService {
6865 this . $nodeModulesDependenciesBuilder . getProductionDependencies ( projectData . projectDir )
6966 . filter ( dep => dep . nativescript && this . $fs . exists ( path . join ( dep . directory , "platforms" , platformData . platformNameLowerCase ) ) )
7067 . 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 ) ;
7570 } ) ;
7671
7772 this . $logger . trace ( `Set nativeChanged to ${ this . _changesInfo . nativeChanged } .` ) ;
@@ -220,7 +215,7 @@ export class ProjectChangesService implements IProjectChangesService {
220215 return false ;
221216 }
222217
223- private containsNewerFiles ( dir : string , projectData : IProjectData , processFunc ?: ( filePath : string , projectData : IProjectData ) => boolean ) : boolean {
218+ private containsNewerFiles ( dir : string , projectData : IProjectData ) : boolean {
224219 const dirName = path . basename ( dir ) ;
225220 this . $logger . trace ( `containsNewerFiles will check ${ dir } ` ) ;
226221 if ( _ . startsWith ( dirName , '.' ) ) {
@@ -242,23 +237,12 @@ export class ProjectChangesService implements IProjectChangesService {
242237 const changed = this . isFileModified ( fileStats , filePath ) ;
243238
244239 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 ;
258242 }
259243
260244 if ( fileStats . isDirectory ( ) ) {
261- if ( this . containsNewerFiles ( filePath , projectData , processFunc ) ) {
245+ if ( this . containsNewerFiles ( filePath , projectData ) ) {
262246 this . $logger . trace ( `containsNewerFiles returns true for ${ dir } .` ) ;
263247 return true ;
264248 }
@@ -281,29 +265,5 @@ export class ProjectChangesService implements IProjectChangesService {
281265
282266 return changed ;
283267 }
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- }
308268}
309269$injector . register ( "projectChangesService" , ProjectChangesService ) ;
0 commit comments