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

Provide easier access to commitizen config to prompters #757

Open
ThisIsMissEm opened this issue Jul 28, 2020 · 2 comments
Open

Provide easier access to commitizen config to prompters #757

ThisIsMissEm opened this issue Jul 28, 2020 · 2 comments

Comments

@ThisIsMissEm
Copy link

Currently when writing a prompter, e.g., cz-conventional-commit, if you wish to integrate with commitizen configuration then you need to do the following:

var configLoader = require('commitizen').configLoader;
configLoader.load() // synchronous, not a promise

I think it'd be nicer to actually have commitizen inject said configuration into prompters, e.g.,

module.exports = {
  prompter: function myAdapter(inquirer, config, commit) {
  }
}

This would remove the backwards dependency from prompters to commitizen, and reduce the need to test that config actually was loaded correctly when testing prompters, and allow for standardised configuration between all prompters. It could also be done in a backwards compatible manner by checking the length of the prompter function (that tells you how many arguments it expects)

@jimthedev
Copy link
Member

I agree. I think this is a good idea. It'd be a breaking change but certainly would be an improvement.

@ThisIsMissEm
Copy link
Author

@jimthedev I don't think it'd be a breaking change, as you can check if the prompter function has an arity of 2 or 3, by using function#length, e.g.,

function current(cz, commit) { }
function proposed(inquirer, config, commit) { }

console.log(current.length == 2)
console.log(proposed.length == 3)

Allowing you to switch between the previous API and the new one.

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

No branches or pull requests

3 participants