Skip to content

Commit 8901a1b

Browse files
committed
refactor(project-data): add getNsConfig private method
1 parent 461f597 commit 8901a1b

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

lib/project-data.ts

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -94,17 +94,13 @@ export class ProjectData implements IProjectData {
9494
projectDir = this.projectDir;
9595
}
9696

97-
const configNSFilePath = path.join(projectDir, constants.CONFIG_NS_FILE_NAME);
97+
const configNS = this.getNsConfig(projectDir);
9898
let absoluteAppResourcesDirPath: string;
9999

100-
if (this.$fs.exists(configNSFilePath)) {
101-
const configNS = this.$fs.readJson(configNSFilePath);
102-
103-
if (configNS && configNS[constants.CONFIG_NS_APP_RESOURCES_ENTRY]) {
104-
const appResourcesDirPath = configNS[constants.CONFIG_NS_APP_RESOURCES_ENTRY];
100+
if (configNS && configNS[constants.CONFIG_NS_APP_RESOURCES_ENTRY]) {
101+
const appResourcesDirPath = configNS[constants.CONFIG_NS_APP_RESOURCES_ENTRY];
105102

106-
absoluteAppResourcesDirPath = path.resolve(projectDir, appResourcesDirPath);
107-
}
103+
absoluteAppResourcesDirPath = path.resolve(projectDir, appResourcesDirPath);
108104
}
109105

110106
return absoluteAppResourcesDirPath || path.join(this.getAppDirectoryPath(projectDir), constants.APP_RESOURCES_FOLDER_NAME);
@@ -115,22 +111,28 @@ export class ProjectData implements IProjectData {
115111
projectDir = this.projectDir;
116112
}
117113

118-
const configNSFilePath = path.join(projectDir, constants.CONFIG_NS_FILE_NAME);
114+
const configNS = this.getNsConfig(projectDir);
119115
let absoluteAppDirPath: string;
120116

121-
if (this.$fs.exists(configNSFilePath)) {
122-
const configNS = this.$fs.readJson(configNSFilePath);
123-
124-
if (configNS && configNS[constants.CONFIG_NS_APP_ENTRY]) {
125-
const appDirPath = configNS[constants.CONFIG_NS_APP_ENTRY];
117+
if (configNS && configNS[constants.CONFIG_NS_APP_ENTRY]) {
118+
const appDirPath = configNS[constants.CONFIG_NS_APP_ENTRY];
126119

127-
absoluteAppDirPath = path.resolve(projectDir, appDirPath);
128-
}
120+
absoluteAppDirPath = path.resolve(projectDir, appDirPath);
129121
}
130122

131123
return absoluteAppDirPath || path.join(projectDir, constants.APP_FOLDER_NAME);
132124
}
133125

126+
private getNsConfig(projectDir: string): Object {
127+
const configNSFilePath = path.join(projectDir, constants.CONFIG_NS_FILE_NAME);
128+
129+
if (!this.$fs.exists(configNSFilePath)) {
130+
return null;
131+
}
132+
133+
return this.$fs.readJson(configNSFilePath);
134+
}
135+
134136
private getProjectType(): string {
135137
let detectedProjectType = _.find(ProjectData.PROJECT_TYPES, (projectType) => projectType.isDefaultProjectType).type;
136138

0 commit comments

Comments
 (0)