Giter Site home page Giter Site logo

Comments (14)

sarbbottam avatar sarbbottam commented on May 7, 2024 26

I could get commitizen and cz-conventional-changelog work for non-node-git-repo with global installation.

Here are the steps that I have followed.

  • $ npm i -g commitizen cz-conventional-changelog
  • $ echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc; create .czrc
  • $ cd non-node-git-repo
  • $ touch foo
  • git cz -a

Hope it will be helpful.

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024 1

Huh, ok I'll have to dig in more. Perhaps it is a bug. Thanks for working
on it w/me.
On Wed, Nov 25, 2015 at 6:32 PM Sébastien Barré [email protected]
wrote:

I'm afraid neither the above, nor a resolved path did the trick...

{
"path": "/Volumes/Users/barre/.npm-packages/lib/node_modules/cz-conventional-changelog"
}

still getting

$ git cz -a
Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?
path.js:481
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at Object.posix.join (path.js:481:13)
at getNearestProjectRootDirectory (/Volumes/Users/barre/.npm-packages/lib/node_modules/commitizen/dist/commitizen/adapter.js:138:28)


Reply to this email directly or view it on GitHub
#83 (comment).

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024 1

@sarbbottam That would be great if you could put in a README PR! 👍

@sebastienbarre Yes this was a nice PR from someone that replace how I was using require and instead using .resolve which is much more consistent behavior with how other node modules typically let you provide input. Cheers to the contributors. :)

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024

@sebastienbarre Sorry I was a bit slow to reply. Good question, though!

Our config loader actually allows for this. You can use either .cz.json or .czrc. Just throw your config in there and we'll pick up the config. 👍

Hopefully that works!

from cz-cli.

sebastienbarre avatar sebastienbarre commented on May 7, 2024

Thanks. Interesting! Failing for me:

$ git cz -a
Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?
path.js:481
      throw new TypeError('Arguments to path.join must be strings');
            ^
TypeError: Arguments to path.join must be strings
    at Object.posix.join (path.js:481:13)
    at getNearestProjectRootDirectory (/Volumes/Users/barre/.npm-packages/lib/node_modules/commitizen/dist/commitizen/adapter.js:138:28)
    at gitCz (/Volumes/Users/barre/.npm-packages/lib/node_modules/commitizen/dist/cli/strategies/git-cz.js:74:58)
    at Object.bootstrap (/Volumes/Users/barre/.npm-packages/lib/node_modules/commitizen/dist/cli/git-cz.js:29:27)

Maybe I'm not using it properly, here is my ~/.czrc:

{
  "config": {
    "commitizen": {
      "path": node_modules/cz-conventional-changelog"
    }
  }
}

I also tried

      "path": "~/.npm-packages/lib/node_modules/cz-conventional-changelog"

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024

Ah yes, can you try:

{
  "path": "~/.npm-packages/lib/node_modules/cz-conventional-changelog"
}

I've also not actually tried using the ~ in the path but hopefully it would work. If not we could probably implement some kind of way to resolve ~ to a homedir.

from cz-cli.

sebastienbarre avatar sebastienbarre commented on May 7, 2024

I'm afraid neither the above, nor a resolved path did the trick...

{
  "path": "/Volumes/Users/barre/.npm-packages/lib/node_modules/cz-conventional-changelog"
}

still getting

$ git cz -a
Error: Could not locate node_modules in your project's root directory. Did you forget to npm init or npm install?
path.js:481
      throw new TypeError('Arguments to path.join must be strings');
            ^
TypeError: Arguments to path.join must be strings
    at Object.posix.join (path.js:481:13)
    at getNearestProjectRootDirectory (/Volumes/Users/barre/.npm-packages/lib/node_modules/commitizen/dist/commitizen/adapter.js:138:28)

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024

I have this resolved, just working on fixing some tests it broke as a result. Will be in the next release.

from cz-cli.

sebastienbarre avatar sebastienbarre commented on May 7, 2024

Sweet, thanks

from cz-cli.

jimthedev avatar jimthedev commented on May 7, 2024

Ok so this was supposed to be simple but my tests alerted me to the fact that it isn't as simple as I'd hoped. This is due to two special places that the config loader is used in:

  1. Our test suite
  2. the commitizen init command, which attempts to make sure that it doesn't overwrite any existing adapter configs that might be up the tree.

So why are these two cases special? Well, simply put, the config loader needs two different traversal modes to handle them:

  1. Unbounded mode (the current default) - In this mode the config loader can traverse up the tree all the way to the drive root.
  2. Upper bounded mode - In this mode the config loader can only traverse up the tree to a certain directory. Once it gets to that directory it will stop the traversal. We need this mode specifically for tests because commitizen actually uses commitizen itself and we don't want the tests to detect our own config as valid. For commitizen init we need to allow people to choose if they want unbounded traversal (the default) or if they want to add an upper boundary during init.

Just wanted to give an update. 👍

from cz-cli.

sebastienbarre avatar sebastienbarre commented on May 7, 2024

Thanks @jimthedev ; can you point me to the traversal code, out of curiosity?

from cz-cli.

yu-yuxuan avatar yu-yuxuan commented on May 7, 2024

I create symbolic link to solve this problem.
node_modules is in the /Users/yuyuxuan.
Suppose my git repository is /Volumes/Transcend/Study/English/New_concept/New_concept_dictation
I use ln -sf ~/node_modules . at the location /Volumes/Transcend/

from cz-cli.

sebastienbarre avatar sebastienbarre commented on May 7, 2024

@sarbbottam the scenario you described didn't work when I created the issue, but it seems to have been fixed by @jimthedev since then. Which is great. Thanks to all.

from cz-cli.

sarbbottam avatar sarbbottam commented on May 7, 2024

@jimthedev let me know if you would prefer a PR to update the README with

  • $ npm i -g commitizen cz-conventional-changelog
  • $ echo '{ "path": "cz-conventional-changelog" }' > ~/.czrc; create .czrc
  • $ cd non-node-git-repo
  • $ touch foo
  • git cz -a

from cz-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.