Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use cosmiconfig to load config #888

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pmcelhaney
Copy link
Contributor

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
var configs = ['.czrc', '.cz.json', 'package.json'];
async function load(config, cwd) {
const explorer = cosmiconfig("commitizen", {
packageProp: "config.commitizen",
Copy link
Contributor Author

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?

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

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use cosmiconfig so users can use whatever config file extension they want
1 participant