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

Function loadConfig

@commitlint/cli/src/cli.ts:489–508  ·  view source on GitHub ↗
(flags: CliFlags)

Source from the content-addressed store, hash-verified

487}
488
489async function loadConfig(flags: CliFlags): Promise<QualifiedConfig> {
490 const loaded = await load(getSeed(flags), {
491 cwd: flags.cwd,
492 file: flags.config,
493 });
494
495 // `--default-config` falls back to the built-in default config when
496 // config resolution yields no rules (e.g. no config file was found).
497 // The default config is prepended so user-supplied --extends configs
498 // keep precedence over it.
499 if (flags["default-config"] && Object.keys(loaded.rules).length === 0) {
500 const extendsWithDefault = [resolveDefaultConfig(flags), ...(flags.extends || [])];
501 return load(getSeed({ ...flags, extends: extendsWithDefault }), {
502 cwd: flags.cwd,
503 file: flags.config,
504 });
505 }
506
507 return loaded;
508}
509
510function resolveDefaultConfig(flags: CliFlags): string {
511 // Resolve from the cli package itself first so the fallback works without

Callers 1

mainFunction · 0.70

Calls 3

loadFunction · 0.85
getSeedFunction · 0.85
resolveDefaultConfigFunction · 0.85

Tested by

no test coverage detected