MCPcopy Create free account
hub / github.com/conventional-changelog/commitlint / getConfigContents

Function getConfigContents

@commitlint/load/src/load.test.ts:275–300  ·  view source on GitHub ↗
({
		filename,
		isEsm,
	}: {
		filename: string;
		isEsm: boolean;
	})

Source from the content-addressed store, hash-verified

273 ];
274
275 const getConfigContents = ({
276 filename,
277 isEsm,
278 }: {
279 filename: string;
280 isEsm: boolean;
281 }): string | NodeJS.ArrayBufferView => {
282 if (filename === "package.json") {
283 const configPath = path.join(__dirname, `../fixtures/${template}-config/.commitlintrc.json`);
284 const commitlint = JSON.parse(readFileSync(configPath, { encoding: "utf-8" }));
285 return JSON.stringify({ commitlint });
286 } else if (filename === "package.yaml") {
287 const configPath = path.join(__dirname, `../fixtures/${template}-config/.commitlintrc.yaml`);
288 const yaml = readFileSync(configPath, { encoding: "utf-8" });
289 return `commitlint:\n${yaml.replace(/^/gm, " ")}`;
290 } else {
291 const filePath = ["..", "fixtures", `${template}-config`, filename];
292
293 if (isEsm) {
294 filePath.splice(3, 0, "esm");
295 }
296
297 const configPath = path.join(__dirname, filePath.join("/"));
298 return readFileSync(configPath);
299 }
300 };
301
302 const esmBootstrap = (cwd: string) => {
303 const packageJsonPath = path.join(cwd, "package.json");

Callers 1

load.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected