Skip to content

Commit

Permalink
[jest-config] simplify filter-reduce (#13899)
Browse files Browse the repository at this point in the history
  • Loading branch information
Connormiha committed Feb 11, 2023
1 parent c81dfaf commit 2818bf1
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/jest-config/src/setFromArgv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ export default function setFromArgv(
options: Config.InitialOptions,
argv: Config.Argv,
): Config.InitialOptions {
const argvToOptions = Object.keys(argv)
.filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1)
.reduce((options: Record<string, unknown>, key) => {
const argvToOptions = Object.keys(argv).reduce(
(options: Record<string, unknown>, key) => {
if (argv[key] === undefined || specialArgs.includes(key)) {
return options;
}

switch (key) {
case 'coverage':
options.collectCoverage = argv[key];
Expand Down Expand Up @@ -48,7 +51,9 @@ export default function setFromArgv(
options[key] = argv[key];
}
return options;
}, {});
},
{},
);

return {
...options,
Expand Down

0 comments on commit 2818bf1

Please sign in to comment.