I have a project with the following configuration on my machine:
.czrc in ~ using cz-conventional-changelogcz-conventional-changelogin the main repo, git cz works as one would expect. however, if you try to do work in the submodule director, and run git cz it fails with a path error:
/Users/<username>/.nvm/versions/node/v6.6.0/lib/node_modules/commitizen/dist/commitizen/adapter.js:192
throw error;
^
Error: Could not resolve /Users/<username>/Development/path/to/repo/submodule/node_modules/cz-conventional-changelog. Cannot find module '/Users/<username>/Development/path/to/repo/submodule/node_modules/cz-conventional-changelog'
It's trying to find an install directly in the submodule for some reason. I would have expected it to use the global install, or the installation referenced one directory up (as a submodule of a project that is commitizen-friendly).
As a test, I checked out the same submodule in a separate directory, and git cz worked as expected.
Is there something that would prevent submodules from working like nested directories when using git cz?
Yes, this is tricky because commitizen actually looks up the directory chain for a .git then looks for an installed adapter in package.json. At the moment we don't support submodules in the find config algorithm. I am not opposed to it but it isn't a common enough use-case that we have any existing test cases for it.
@jimthedev fair enough. It's a nice-to-have on my current project, so I might take a stab at it myself, and offer a PR :)
I have this need as well. sad it can't be put in. So what exactly we can do to go around it? Let say your have a .git inside /myProject folder and the actual package.json is in /myProject/anotherSmallProject/ folder?
if you add the correct path in your package.json it should work.
i.e.
"config": {
"commitizen": {
"path": "./anotherSmallProject/node_modules/cz-conventional-changelog"
}
}
Most helpful comment
if you add the correct path in your package.json it should work.
i.e.
"config": { "commitizen": { "path": "./anotherSmallProject/node_modules/cz-conventional-changelog" } }