MCPcopy Index your code
hub / github.com/react-native-community/cli / loadConfigAsync

Function loadConfigAsync

packages/cli-config/src/loadConfig.ts:188–284  ·  view source on GitHub ↗
({
  projectRoot = findProjectRoot(),
  selectedPlatform,
}: {
  projectRoot?: string;
  selectedPlatform?: string;
})

Source from the content-addressed store, hash-verified

186 */
187
188export async function loadConfigAsync({
189 projectRoot = findProjectRoot(),
190 selectedPlatform,
191}: {
192 projectRoot?: string;
193 selectedPlatform?: string;
194}): Promise<Config> {
195 let lazyProject: ProjectConfig;
196 const userConfig = await readConfigFromDiskAsync(projectRoot);
197
198 const initialConfig: Config = {
199 root: projectRoot,
200 get reactNativePath() {
201 return userConfig.reactNativePath
202 ? path.resolve(projectRoot, userConfig.reactNativePath)
203 : resolveReactNativePath(projectRoot);
204 },
205 get reactNativeVersion() {
206 return getReactNativeVersion(initialConfig.reactNativePath);
207 },
208 dependencies: userConfig.dependencies,
209 commands: userConfig.commands,
210 healthChecks: userConfig.healthChecks || [],
211 platforms: userConfig.platforms,
212 assets: userConfig.assets,
213 get project() {
214 if (lazyProject) {
215 return lazyProject;
216 }
217
218 lazyProject = {};
219 for (const platform in finalConfig.platforms) {
220 const platformConfig = finalConfig.platforms[platform];
221 if (platformConfig) {
222 lazyProject[platform] = platformConfig.projectConfig(
223 projectRoot,
224 userConfig.project[platform] || {},
225 );
226 }
227 }
228
229 return lazyProject;
230 },
231 };
232
233 const finalConfig = await Array.from(
234 new Set([
235 ...Object.keys(userConfig.dependencies),
236 ...findDependencies(projectRoot),
237 ]),
238 ).reduce(async (accPromise: Promise<Config>, dependencyName) => {
239 const acc = await accPromise;
240 const localDependencyRoot =
241 userConfig.dependencies[dependencyName] &&
242 userConfig.dependencies[dependencyName].root;
243 try {
244 let root =
245 localDependencyRoot ||

Callers 3

setupAndRunFunction · 0.90
getHealthchecksFunction · 0.90
index-test.tsFile · 0.85

Calls 7

findProjectRootFunction · 0.90
readConfigFromDiskAsyncFunction · 0.90
resolveNodeModuleDirFunction · 0.90
findDependenciesFunction · 0.85
assignFunction · 0.85
removeDuplicateCommandsFunction · 0.85

Tested by

no test coverage detected