Skip to content

Commit

Permalink
fix: Cannot start test script if config-overrides path is set via c…
Browse files Browse the repository at this point in the history
…ommand line argument (#595)
  • Loading branch information
bencergazda committed Feb 15, 2022
1 parent 6372ca2 commit aa6c91c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 4 additions & 1 deletion overrides/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@ packageJson.jest = jestOverrides;
// override createJestConfig in memory
require.cache[require.resolve(createJestConfigPath)].exports =
() => overrides.jest(rewireJestConfig(config));
// Passing the --scripts-version on to the original test script can result
// Passing the --scripts-version and --config-overrides on to the original test script can result
// in the test script rejecting it as an invalid option. So strip it out of
// the command line arguments before invoking the test script.
if (paths.customScriptsIndex > -1) {
process.argv.splice(paths.customScriptsIndex, 2);
}
if (paths.configOverridesIndex > -1) {
process.argv.splice(paths.configOverridesIndex, 2);
}

module.exports = require(createJestConfigPath);
6 changes: 4 additions & 2 deletions scripts/utils/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ var config_overrides = customPath
: `${ projectDir }/config-overrides`;
const co_index = process.argv.indexOf('--config-overrides');

var has_co_argument = false;
if (co_index > -1 && co_index + 1 <= process.argv.length) {
has_co_argument = true;
config_overrides = path.resolve(process.argv[co_index + 1]);
process.argv.splice(co_index, 2);
}

const scriptVersion = custom_scripts || 'react-scripts';
Expand All @@ -33,5 +34,6 @@ const paths = require(modulePath + '/config/paths');
module.exports = Object.assign({
scriptVersion: modulePath,
configOverrides: config_overrides,
customScriptsIndex: (custom_scripts ? cs_index : -1)
customScriptsIndex: (custom_scripts ? cs_index : -1),
configOverridesIndex: (has_co_argument ? co_index : -1),
}, paths);

0 comments on commit aa6c91c

Please sign in to comment.