MCPcopy
hub / github.com/jestjs/jest / readConfig

Function readConfig

packages/jest-config/src/index.ts:80–121  ·  view source on GitHub ↗
(
  argv: Config.Argv,
  packageRootOrConfig: string | Config.InitialOptions,
  // 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,
  parentConfigDirname?: string | null,
  projectIndex = Number.POSITIVE_INFINITY,
  skipMultipleConfigError = false,
)

Source from the content-addressed store, hash-verified

78}
79
80export async function readConfig(
81 argv: Config.Argv,
82 packageRootOrConfig: string | Config.InitialOptions,
83 // Whether it needs to look into `--config` arg passed to CLI.
84 // It only used to read initial config. If the initial config contains
85 // `project` property, we don't want to read `--config` value and rather
86 // read individual configs for every project.
87 skipArgvConfigOption?: boolean,
88 parentConfigDirname?: string | null,
89 projectIndex = Number.POSITIVE_INFINITY,
90 skipMultipleConfigError = false,
91): Promise<ReadConfig> {
92 const {config: initialOptions, configPath} = await readInitialOptions(
93 argv.config,
94 {
95 packageRootOrConfig,
96 parentConfigDirname,
97 readFromCwd: skipArgvConfigOption,
98 skipMultipleConfigError,
99 },
100 );
101
102 const packageRoot =
103 typeof packageRootOrConfig === 'string'
104 ? path.resolve(packageRootOrConfig)
105 : undefined;
106 const {options, hasDeprecationWarnings} = await normalize(
107 initialOptions,
108 argv,
109 configPath,
110 projectIndex,
111 skipArgvConfigOption && !(packageRoot === parentConfigDirname),
112 );
113
114 const {globalConfig, projectConfig} = groupOptions(options);
115 return {
116 configPath,
117 globalConfig,
118 hasDeprecationWarnings,
119 projectConfig,
120 };
121}
122
123const groupOptions = (
124 options: Config.ProjectConfig & Config.GlobalConfig,

Callers 2

readConfigsFunction · 0.70
readConfig.test.tsFile · 0.50

Calls 4

readInitialOptionsFunction · 0.85
groupOptionsFunction · 0.85
normalizeFunction · 0.70
resolveMethod · 0.45

Tested by

no test coverage detected