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

Function loadConfig

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

Source from the content-addressed store, hash-verified

532}
533
534async function loadConfig(flags: CliFlags): Promise<QualifiedConfig> {
535 const loaded = await load(getSeed(flags), {
536 cwd: flags.cwd,
537 file: flags.config,
538 });
539
540 // `--default-config` falls back to the built-in default config when
541 // config resolution yields no rules (e.g. no config file was found).
542 // The default config is prepended so user-supplied --extends configs
543 // keep precedence over it.
544 if (flags["default-config"] && Object.keys(loaded.rules).length === 0) {
545 const extendsWithDefault = [resolveDefaultConfig(flags), ...(flags.extends || [])];
546 return load(getSeed({ ...flags, extends: extendsWithDefault }), {
547 cwd: flags.cwd,
548 file: flags.config,
549 });
550 }
551
552 return loaded;
553}
554
555function resolveDefaultConfig(flags: CliFlags): string {
556 // 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