Skip to content

Commit 38ec62d

Browse files
motiz88facebook-github-bot
authored andcommitted
Don't mutate argument to loadConfig
Summary: Changelog: **[Fix]**: `metro-config`: Don't mutate argument to `loadConfig`. This enables some improvements to type safety in how we define Metro's core CLI commands (coming up in a separate diff). Reviewed By: jacdebug Differential Revision: D43774991 fbshipit-source-id: 3f66f287e7d34764c8946a3a84483515dbf5d376
1 parent 34c313d commit 38ec62d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

packages/metro-config/src/configTypes.flow.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export type ConfigT = $ReadOnly<{
241241
}>,
242242
}>;
243243

244-
export type YargArguments = {
244+
export type YargArguments = $ReadOnly<{
245245
config?: string,
246246
cwd?: string,
247247
port?: string | number,
@@ -259,4 +259,4 @@ export type YargArguments = {
259259
runInspectorProxy?: boolean,
260260
verbose?: boolean,
261261
...
262-
};
262+
}>;

packages/metro-config/src/loadConfig.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ function overrideConfigWithArguments(
265265
* @return {object} Configuration returned
266266
*/
267267
async function loadConfig(
268-
argv?: YargArguments = {},
268+
argvInput?: YargArguments = {},
269269
defaultConfigOverrides?: InputConfigT = {},
270270
): Promise<ConfigT> {
271-
argv.config = overrideArgument(argv.config);
271+
const argv = {...argvInput, config: overrideArgument(argvInput.config)};
272272

273273
const configuration = await loadMetroConfigFromDisk(
274274
argv.config,

0 commit comments

Comments
 (0)