@@ -55,9 +55,8 @@ export class ProjectData implements IProjectData {
5555 const projectFilePath = this . getProjectFilePath ( projectDir ) ;
5656
5757 if ( this . $fs . exists ( projectFilePath ) ) {
58- let packageJsonContent : any = null ;
59- packageJsonContent = this . $fs . readText ( projectFilePath ) ;
60- const nsConfigContent : any = this . getNsConfigContent ( projectDir ) ;
58+ const packageJsonContent = this . $fs . readText ( projectFilePath ) ;
59+ const nsConfigContent = this . getNsConfigContent ( projectDir ) ;
6160
6261 this . initializeProjectDataFromContent ( packageJsonContent , nsConfigContent , projectDir ) ;
6362 }
@@ -72,9 +71,9 @@ export class ProjectData implements IProjectData {
7271 projectDir = projectDir || this . $projectHelper . projectDir || "" ;
7372 const projectFilePath = this . getProjectFilePath ( projectDir ) ;
7473 // If no project found, projectDir should be null
75- let nsData : any = null ;
76- let nsConfig : any = null ;
77- let packageJsonData : any = null ;
74+ let nsData = null ;
75+ let nsConfig : INsConfig = null ;
76+ let packageJsonData = null ;
7877
7978 try {
8079 packageJsonData = parseJson ( packageJsonContent ) ;
@@ -86,7 +85,7 @@ export class ProjectData implements IProjectData {
8685 }
8786
8887 try {
89- nsConfig = nsconfigContent ? parseJson ( nsconfigContent ) : null ;
88+ nsConfig = nsconfigContent ? < INsConfig > parseJson ( nsconfigContent ) : null ;
9089 } catch ( err ) {
9190 this . $errors . failWithoutHelp ( `The NativeScript configuration file ${ constants . CONFIG_NS_FILE_NAME } is corrupted. ${ EOL } ` +
9291 `Consider restoring an earlier version from your source control or backup.${ EOL } ` +
@@ -125,15 +124,9 @@ export class ProjectData implements IProjectData {
125124 }
126125
127126 public getAppResourcesDirectoryPath ( projectDir ?: string ) : string {
128- if ( ! projectDir ) {
129- projectDir = this . projectDir ;
130- }
131-
132- if ( ! projectDir ) {
133- return null ;
134- }
127+ const appResourcesRelativePath = this . getAppResourcesRelativeDirectoryPath ( ) ;
135128
136- return path . resolve ( projectDir , this . getAppResourcesRelativeDirectoryPath ( ) ) ;
129+ return this . resolveToProjectDir ( appResourcesRelativePath , projectDir ) ;
137130 }
138131
139132 public getAppResourcesRelativeDirectoryPath ( ) : string {
@@ -145,15 +138,9 @@ export class ProjectData implements IProjectData {
145138 }
146139
147140 public getAppDirectoryPath ( projectDir ?: string ) : string {
148- if ( ! projectDir ) {
149- projectDir = this . projectDir ;
150- }
151-
152- if ( ! projectDir ) {
153- return null ;
154- }
141+ const appRelativePath = this . getAppDirectoryRelativePath ( ) ;
155142
156- return path . resolve ( projectDir , this . getAppDirectoryRelativePath ( ) ) ;
143+ return this . resolveToProjectDir ( appRelativePath , projectDir ) ;
157144 }
158145
159146 public getAppDirectoryRelativePath ( ) : string {
@@ -174,6 +161,18 @@ export class ProjectData implements IProjectData {
174161 return this . $fs . readText ( configNSFilePath ) ;
175162 }
176163
164+ private resolveToProjectDir ( pathToResolve : string , projectDir ?: string ) : string {
165+ if ( ! projectDir ) {
166+ projectDir = this . projectDir ;
167+ }
168+
169+ if ( ! projectDir ) {
170+ return null ;
171+ }
172+
173+ return path . resolve ( projectDir , pathToResolve ) ;
174+ }
175+
177176 private getProjectType ( ) : string {
178177 let detectedProjectType = _ . find ( ProjectData . PROJECT_TYPES , ( projectType ) => projectType . isDefaultProjectType ) . type ;
179178
0 commit comments