@@ -55,9 +55,8 @@ export class ProjectData implements IProjectData {
55
55
const projectFilePath = this . getProjectFilePath ( projectDir ) ;
56
56
57
57
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 ) ;
61
60
62
61
this . initializeProjectDataFromContent ( packageJsonContent , nsConfigContent , projectDir ) ;
63
62
}
@@ -72,9 +71,9 @@ export class ProjectData implements IProjectData {
72
71
projectDir = projectDir || this . $projectHelper . projectDir || "" ;
73
72
const projectFilePath = this . getProjectFilePath ( projectDir ) ;
74
73
// 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 ;
78
77
79
78
try {
80
79
packageJsonData = parseJson ( packageJsonContent ) ;
@@ -86,7 +85,7 @@ export class ProjectData implements IProjectData {
86
85
}
87
86
88
87
try {
89
- nsConfig = nsconfigContent ? parseJson ( nsconfigContent ) : null ;
88
+ nsConfig = nsconfigContent ? < INsConfig > parseJson ( nsconfigContent ) : null ;
90
89
} catch ( err ) {
91
90
this . $errors . failWithoutHelp ( `The NativeScript configuration file ${ constants . CONFIG_NS_FILE_NAME } is corrupted. ${ EOL } ` +
92
91
`Consider restoring an earlier version from your source control or backup.${ EOL } ` +
@@ -125,15 +124,9 @@ export class ProjectData implements IProjectData {
125
124
}
126
125
127
126
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 ( ) ;
135
128
136
- return path . resolve ( projectDir , this . getAppResourcesRelativeDirectoryPath ( ) ) ;
129
+ return this . resolveToProjectDir ( appResourcesRelativePath , projectDir ) ;
137
130
}
138
131
139
132
public getAppResourcesRelativeDirectoryPath ( ) : string {
@@ -145,15 +138,9 @@ export class ProjectData implements IProjectData {
145
138
}
146
139
147
140
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 ( ) ;
155
142
156
- return path . resolve ( projectDir , this . getAppDirectoryRelativePath ( ) ) ;
143
+ return this . resolveToProjectDir ( appRelativePath , projectDir ) ;
157
144
}
158
145
159
146
public getAppDirectoryRelativePath ( ) : string {
@@ -174,6 +161,18 @@ export class ProjectData implements IProjectData {
174
161
return this . $fs . readText ( configNSFilePath ) ;
175
162
}
176
163
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
+
177
176
private getProjectType ( ) : string {
178
177
let detectedProjectType = _ . find ( ProjectData . PROJECT_TYPES , ( projectType ) => projectType . isDefaultProjectType ) . type ;
179
178
0 commit comments