Closed bahmutov closed 8 years ago
@bahmutov Thanks for the great idea. I've considered this as well but haven't had time to implement yet. I do intend to eventually.
Historically, the reason behind using the path is two fold:
I agree that it needs some work to provide a module key instead of a path key. We could likely handle resolving the paths internally in commitizen. Currently we handle the differences between npm 2 and npm 3 in a very hacky way by trying to load one, then the other (incorrect: see here) that ideally we'd eventually remove once npm2 falls out of favor.
Edit: My link here on finding npm modules was incorrect. That is how we used to do it. We now use the find-node-modules plugin so I'd imagine we could implement this relatively easily.
cool, for now I implemented running the adapter from my own module without going through commitizen bin script, here is the change https://github.com/bahmutov/pre-git/commit/1f35af70e6d428520bd79ed9fea98740a4f76592 I wanted to use commitizen as a module, but the src/index.js is a dummy file, right? https://github.com/commitizen/cz-cli/blob/master/src/index.js
You are correct. :) It is just a dummy file since up until now it has really only been used as a cli. Time to expose the api a bit better in a library I suppose.
One quick edit, too. My post above on finding npm modules was incorrect. That is how we used to do it. We now use the find-node-modules plugin so I'd imagine we could implement this relatively easily.
Also, @bahmutov, please upgrade to the latest version of commitizen's cli and use the following package.json syntax since czConfig will be deprecated in 3.0.0.
config: {
commitizen: {
path: './node-modules/cz-conventional-changelog'
}
}
Why do we load a path to an adaptor and not an actual module? I like to distribute the commitizen with my pre-git module as
pre-git
dependency by default. But commitizen cannot find the adaptor pathThis breaks between npm 2 and 3 - npm3 seems to flatten paths, while npm2 leaves the paths nested. I believe it would be better to just require the adaptor by name, rather than use
node_modules
path, or at least check if the path resolves or not.