◐ Shell
clean mode source ↗

feat: use cosmiconfig to load config by pmcelhaney · Pull Request #888 · commitizen/cz-cli

@pmcelhaney

In theory with this change commitizen will work when it's run from a subdirectory.

I haven't fully tested yet but I want to get the WIP out there and get some eyes on it.

fixes #773

it should now be able to find the config file from a subdirectory

fixes commitizen#773

pmcelhaney

var configs = ['.czrc', '.cz.json', 'package.json'];
async function load(config, cwd) {
const explorer = cosmiconfig("commitizen", {
packageProp: "config.commitizen",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look for the config.commitizen property in package.json. Does it also need to look for a commitizen property at the root?

pmcelhaney

const explorer = cosmiconfig("commitizen", {
packageProp: "config.commitizen",
searchPlaces: [".czrc", ".cz.json", "package.json"],
searchFrom: cwd,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default, this is the current working directory. Not sure what the cwd argument represents here (maybe it's just for tests?) so I made this option explicit just in case.