Skip to content
commitizenPublic

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

@commitizen/config

Finds and reads a project's commitizen configuration. This is the loader behind require('commitizen').configLoader.load(), published on its own so adapters can read their settings without depending on all of commitizen.

npm install @commitizen/config

Usage

import { load } from '@commitizen/config';

const config = load() || {};

It also works with require():

const { load } = require('@commitizen/config');

load(configPath?, cwd?)

Returns the commitizen config object, or undefined when there is none.

  • With configPath: reads that file, relative to cwd, and nothing else.
  • Without it: starting in cwd (default: the current directory) and walking up, uses the first directory that has .czrc, .cz.json or package.json, in that order. In a package.json the config is config.commitizen (or the deprecated czConfig, with a warning). The search stops at that directory even when its package.json has no commitizen config.
  • If that finds nothing: tries the same files in the home directory (USERPROFILE, HOMEPATH, then HOME).

.czrc and other files without a .json or .js extension may contain comments. A file with invalid JSON, or that isn't UTF-8, throws.

CONFIG_FILES

The file names load() looks for, in priority order: ['.czrc', '.cz.json', 'package.json'].

Compatibility

  • Returns the same object as require('commitizen').configLoader.load(). commitizen re-exports this package, so both always agree.
  • Node.js ^22.23.5 || ^24.22.3 || >=26.13.1. The package is an ES module with no top-level await, so require() works.
  • Unlike the copy inside earlier commitizen versions, it doesn't skip the home directory while tests run under Mocha. Tests that call load() should point HOME (and USERPROFILE on Windows) at an empty directory.

License

MIT

About

No description, website, or topics provided.

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages