Skip to content
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

fix(read-config): allow multiple projects with programmatic usage #11307

Merged
merged 14 commits into from Apr 23, 2021
14 changes: 6 additions & 8 deletions packages/jest-config/src/index.ts
Expand Up @@ -38,7 +38,7 @@ export async function readConfig(
// `project` property, we don't want to read `--config` value and rather
// read individual configs for every project.
skipArgvConfigOption?: boolean,
parentConfigPath?: Config.Path | null,
parentConfigDirname?: Config.Path | null,
projectIndex: number = Infinity,
): Promise<ReadConfig> {
let rawOptions:
Expand All @@ -47,8 +47,7 @@ export async function readConfig(
let configPath = null;

if (typeof packageRootOrConfig !== 'string') {
if (parentConfigPath) {
const parentConfigDirname = path.dirname(parentConfigPath);
if (parentConfigDirname) {
rawOptions = packageRootOrConfig;
rawOptions.rootDir = rawOptions.rootDir
? replaceRootDirInPath(parentConfigDirname, rawOptions.rootDir)
Expand Down Expand Up @@ -301,10 +300,9 @@ export async function readConfigs(
}

if (projects.length > 0) {
const projectIsCwd =
process.platform === 'win32'
? projects[0] === tryRealpath(process.cwd())
: projects[0] === process.cwd();
const cwd =
process.platform === 'win32' ? tryRealpath(process.cwd()) : process.cwd();
const projectIsCwd = projects[0] === cwd;

const parsedConfigs = await Promise.all(
projects
Expand Down Expand Up @@ -332,7 +330,7 @@ export async function readConfigs(
argv,
root,
skipArgvConfigOption,
configPath,
configPath ? path.dirname(configPath) : cwd,
projectIndex,
);
}),
Expand Down