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

Function getConfigContents

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

Source from the content-addressed store, hash-verified

244 ];
245
246 const getConfigContents = ({
247 filename,
248 isEsm,
249 }: {
250 filename: string;
251 isEsm: boolean;
252 }): string | NodeJS.ArrayBufferView => {
253 if (filename === "package.json") {
254 const configPath = path.join(__dirname, `../fixtures/${template}-config/.commitlintrc.json`);
255 const commitlint = JSON.parse(readFileSync(configPath, { encoding: "utf-8" }));
256 return JSON.stringify({ commitlint });
257 } else if (filename === "package.yaml") {
258 const configPath = path.join(__dirname, `../fixtures/${template}-config/.commitlintrc.yaml`);
259 const yaml = readFileSync(configPath, { encoding: "utf-8" });
260 return `commitlint:\n${yaml.replace(/^/gm, " ")}`;
261 } else {
262 const filePath = ["..", "fixtures", `${template}-config`, filename];
263
264 if (isEsm) {
265 filePath.splice(3, 0, "esm");
266 }
267
268 const configPath = path.join(__dirname, filePath.join("/"));
269 return readFileSync(configPath);
270 }
271 };
272
273 const esmBootstrap = (cwd: string) => {
274 const packageJsonPath = path.join(cwd, "package.json");

Callers 1

load.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected