-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow configuration object in projects array #5176
Changes from 2 commits
0d4e3b7
0a4cf98
75615e6
fb2b4d4
50d01f7
b61f30e
b227bad
3e4c825
d91e999
c9d5fec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,24 +17,34 @@ import readConfigFileAndSetRootDir from './read_config_file_and_set_root_dir'; | |
|
||
function readConfig( | ||
argv: Argv, | ||
packageRoot: string, | ||
packageRootOrConfig: Path | ProjectConfig, | ||
// Whether it needs to look into `--config` arg passed to CLI. | ||
// It only used to read initial config. If the initial config contains | ||
// `project` property, we don't want to read `--config` value and rather | ||
// read individual configs for every project. | ||
skipArgvConfigOption?: boolean, | ||
parentConfigPath?: ?Path, | ||
): { | ||
configPath: ?Path, | ||
globalConfig: GlobalConfig, | ||
hasDeprecationWarnings: boolean, | ||
projectConfig: ProjectConfig, | ||
} { | ||
let rawOptions; | ||
let configPath; | ||
let configPath = null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there anywhere that requires a |
||
|
||
// A JSON string was passed to `--config` argument and we can parse it | ||
// and use as is. | ||
if (isJSONString(argv.config)) { | ||
if (typeof packageRootOrConfig !== 'string') { | ||
if (parentConfigPath) { | ||
rawOptions = packageRootOrConfig; | ||
rawOptions.rootDir = parentConfigPath; | ||
} else { | ||
throw new Error( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can we have a test for this (mostly for coverage)? |
||
'jest: Cannot use configuration as an object without a file path', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you end this sentence with a full stop (.) ? Also, please capitalize Jest. |
||
); | ||
} | ||
} else if (isJSONString(argv.config)) { | ||
// A JSON string was passed to `--config` argument and we can parse it | ||
// and use as is. | ||
let config; | ||
try { | ||
config = JSON.parse(argv.config); | ||
|
@@ -45,7 +55,7 @@ function readConfig( | |
} | ||
|
||
// NOTE: we might need to resolve this dir to an absolute path in the future | ||
config.rootDir = config.rootDir || packageRoot; | ||
config.rootDir = config.rootDir || packageRootOrConfig; | ||
rawOptions = config; | ||
// A string passed to `--config`, which is either a direct path to the config | ||
// or a path to directory containing `package.json` or `jest.conf.js` | ||
|
@@ -54,7 +64,7 @@ function readConfig( | |
rawOptions = readConfigFileAndSetRootDir(configPath); | ||
} else { | ||
// Otherwise just try to find config in the current rootDir. | ||
configPath = resolveConfigPath(packageRoot, process.cwd()); | ||
configPath = resolveConfigPath(packageRootOrConfig, process.cwd()); | ||
rawOptions = readConfigFileAndSetRootDir(configPath); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does
?
on both sides mean? From my understandingname: ?type
allowsnull
,undefined
or a value, whilename?: type
allowsundefined
or a value.https://flow.org/en/docs/types/primitives/#toc-maybe-types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very proficient with Flow. I just added the
?
on the LHS to satisfy the checker. Maybe I can remove the one left, but the property is optional so I think I'll get an error when it's not explicitly passed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think so 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing it worked.