MCPcopy Create free account
hub / github.com/angular/dev-infra / findAndParseYarnConfiguration

Function findAndParseYarnConfiguration

ng-dev/utils/resolve-yarn-bin.ts:154–175  ·  view source on GitHub ↗

Finds and parses the Yarn configuration file for the given project.

(
  projectDir: string,
)

Source from the content-addressed store, hash-verified

152
153/** Finds and parses the Yarn configuration file for the given project. */
154async function findAndParseYarnConfiguration(
155 projectDir: string,
156): Promise<YarnConfiguration | null> {
157 const files = await Promise.all(
158 yarnConfigFiles.map(async (entry) => ({
159 entry,
160 content: await readFileGracefully(path.join(projectDir, entry.fileName)),
161 })),
162 );
163 const config = files.find((entry) => entry.content !== null);
164 if (config === undefined) {
165 return null;
166 }
167
168 try {
169 return config.entry.parse(config.content!);
170 } catch (e) {
171 Log.debug(`Could not parse determined Yarn configuration file (${config.entry.fileName}).`);
172 Log.debug(`Error:`, e);
173 return null;
174 }
175}
176
177/**
178 * Reads the specified file gracefully.

Callers 1

Calls 1

readFileGracefullyFunction · 0.70

Tested by

no test coverage detected