From b8f6009792092ebec1da167e2d3702451dd12508 Mon Sep 17 00:00:00 2001 From: Kenrick Date: Fri, 22 Nov 2019 19:48:37 +0800 Subject: [PATCH] Apply suggestion from code review --- packages/jest-config/src/index.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/jest-config/src/index.ts b/packages/jest-config/src/index.ts index 38e4f5a8cee2..0df90f5d9c39 100644 --- a/packages/jest-config/src/index.ts +++ b/packages/jest-config/src/index.ts @@ -292,6 +292,11 @@ export function readConfigs( } if (projects.length > 0) { + const projectIsCwd = + process.platform === 'win32' + ? projects[0] === realpath(process.cwd()) + : projects[0] === process.cwd(); + const parsedConfigs = projects .filter(root => { // Ignore globbed files that cannot be `require`d. @@ -308,14 +313,10 @@ export function readConfigs( return true; }) .map((root, projectIndex) => { - // Skip on all except: projectIndex === 0, projects[0] === process.cwd() or realpath(process.cwd()) on Windows, and projects.length === 1 - const skipArgvConfigOption = !( - projectIndex === 0 && - (process.platform === 'win32' - ? projects[0] === realpath(process.cwd()) - : projects[0] === process.cwd()) && - projects.length === 1 - ); + const projectIsTheOnlyProject = + projectIndex === 0 && projects.length === 1; + const skipArgvConfigOption = !(projectIsTheOnlyProject && projectIsCwd); + return readConfig( argv, root,