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

Function getConfigContents

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

Source from the content-addressed store, hash-verified

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

Callers 1

load.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected