Cz-cli: Problem using `git cz` in non-node submodule of project

Created on 20 Sep 2017  路  4Comments  路  Source: commitizen/cz-cli

I have a project with the following configuration on my machine:

  • globally-installed commitizen with .czrc in ~ using cz-conventional-changelog
  • main repo. with package.json set up to use cz-conventional-changelog
  • a submodule that contains a non-node project (no package.json file)

in 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?

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" } }

All 4 comments

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" } }

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scamden picture scamden  路  4Comments

micky2be picture micky2be  路  6Comments

gaurav5430 picture gaurav5430  路  7Comments

rigobauer picture rigobauer  路  4Comments

fendy-g picture fendy-g  路  7Comments