diff --git a/lib/definitions/project.d.ts b/lib/definitions/project.d.ts index d8f77881be..ba58abb0c1 100644 --- a/lib/definitions/project.d.ts +++ b/lib/definitions/project.d.ts @@ -165,6 +165,7 @@ interface IProjectData extends ICreateProjectData { infoPlistPath: string; buildXcconfigPath: string; podfilePath: string; + initialized?: boolean; /** * Defines if the project is a code sharing one. * Value is true when project has nativescript.config and it has `shared: true` in it. diff --git a/lib/project-data.ts b/lib/project-data.ts index a67a3b5b8a..cb1794fb07 100644 --- a/lib/project-data.ts +++ b/lib/project-data.ts @@ -98,6 +98,7 @@ export class ProjectData implements IProjectData { public isShared: boolean; public previewAppSchema: string; public webpackConfigPath: string; + public initialized: boolean; constructor( private $fs: IFileSystem, @@ -116,6 +117,9 @@ export class ProjectData implements IProjectData { } public initializeProjectData(projectDir?: string): void { + if (this.initialized) { + return; + } projectDir = projectDir || this.$projectHelper.projectDir; // If no project found, projectDir should be null @@ -126,6 +130,7 @@ export class ProjectData implements IProjectData { const packageJsonContent = this.$fs.readText(projectFilePath); this.initializeProjectDataFromContent(packageJsonContent, projectDir); + this.initialized = true; } return; diff --git a/lib/services/project-data-service.ts b/lib/services/project-data-service.ts index 5c82d4e6eb..544755d8c4 100644 --- a/lib/services/project-data-service.ts +++ b/lib/services/project-data-service.ts @@ -120,7 +120,6 @@ export class ProjectDataService implements IProjectDataService { this.projectDataCache[projectDir] || this.$injector.resolve(ProjectData); this.projectDataCache[projectDir].initializeProjectData(projectDir); - return this.projectDataCache[projectDir]; }