Skip to content

Commit

Permalink
Don't mutate argument to loadConfig
Browse files Browse the repository at this point in the history
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
  • Loading branch information
motiz88 authored and facebook-github-bot committed Mar 6, 2023
1 parent 34c313d commit 38ec62d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/metro-config/src/configTypes.flow.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export type ConfigT = $ReadOnly<{
}>,
}>;

export type YargArguments = {
export type YargArguments = $ReadOnly<{
config?: string,
cwd?: string,
port?: string | number,
Expand All @@ -259,4 +259,4 @@ export type YargArguments = {
runInspectorProxy?: boolean,
verbose?: boolean,
...
};
}>;
4 changes: 2 additions & 2 deletions packages/metro-config/src/loadConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ function overrideConfigWithArguments(
* @return {object} Configuration returned
*/
async function loadConfig(
argv?: YargArguments = {},
argvInput?: YargArguments = {},
defaultConfigOverrides?: InputConfigT = {},
): Promise<ConfigT> {
argv.config = overrideArgument(argv.config);
const argv = {...argvInput, config: overrideArgument(argvInput.config)};

const configuration = await loadMetroConfigFromDisk(
argv.config,
Expand Down

0 comments on commit 38ec62d

Please sign in to comment.