Skip to content

Commit 3878e97

Browse files
committed
fix: Fix loading Metro config from alternative config path
1 parent 0cbed3d commit 3878e97

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

packages/cli-plugin-metro/src/tools/loadMetroConfig.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,17 @@ export default async function loadMetroConfig(
9292
overrideConfig.reporter = options.reporter;
9393
}
9494

95-
const projectConfig = await resolveConfig(undefined, ctx.root);
95+
const cwd = ctx.root;
96+
const projectConfig = await resolveConfig(options.config, cwd);
9697

9798
if (projectConfig.isEmpty) {
98-
throw new CLIError(`No metro config found in ${ctx.root}`);
99+
if (options.config) {
100+
throw new CLIError(
101+
`No Metro config found at configured config path '${options.config}'`,
102+
);
103+
}
104+
105+
throw new CLIError(`No Metro config found in ${cwd}`);
99106
}
100107

101108
logger.debug(`Reading Metro config from ${projectConfig.filepath}`);
@@ -119,7 +126,10 @@ This warning will be removed in future (https://github.com/facebook/metro/issues
119126
}
120127

121128
return mergeConfig(
122-
await loadConfig({cwd: ctx.root, ...options}),
129+
await loadConfig({
130+
cwd,
131+
...options,
132+
}),
123133
overrideConfig,
124134
);
125135
}

0 commit comments

Comments
 (0)