-
Notifications
You must be signed in to change notification settings - Fork 913
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
Cli format option doesn't load modules #463
Comments
Good catch! Going with
|
Sorry I totally missed your comment! I will update my PR accordingly! Thanks |
I agree with you about the paths and that Do you have tips or tricks on how to get the path of |
How does this sound?
This results in |
I've updated the pull request to allow config-file-relative modules as formatter @marionebl . The approach I used is the same I described above. I'm not sure if that's the way to go, but I don't see a lot of other options without duplicating code. If you have another option which we can explore, I would be happy to help/test/try! Right now the code in my PR supports the following scenarios:
I'd recon the absolute file paths are a bit weird (wouldn't recommend it either), but it's actually being resolved by I know you are not a fan of global modules. My ultimate perfect scenario use case is being able to use it from a pre-built docker image, without installing the project dependencies. It takes our (Bitbucket) Pipelines from an average of 1.5 - 2 min to around 10 sec for commit validation. That's why I would really love global support 😄 |
@byCedric I added a review to your PR. Apart from a minor thing I am fine with all your points - great work! 👍 Are you be interested in maintaining commitlint? I'll be on vacation for two weeks starting on Friday 12th, so I'd introduce you to the project when I am back. What do you think? |
Thanks @marionebl! I'll fix it after I had something to eat! And I'm glad you like the approach too, I think I was a bit lost otherwise 😅 Yeah definitely! Like I said earlier, I like this project, and we (at Peakfijn) are feeling the benefits from using it 😬I'm happy to keep helping 😄Have fun on your vacation! |
I've been busy with some formatters for Commitlint, so far I've created two; json and junit formats.
During initial testing, I encountered some unexpected behavior related to importing these formatters in the CLI package. On line 268, in cli.js, we use
require.resolve
. I mistakenly assumed it would handle global/local modules and absolute/relative file paths. Unfortunately, this isn't the case. I've tried to useflags.cwd
in the resolve method, but this only seems to fix locally installed modules and relative file paths.TL;DR;
Format module resolves must be improved, I suggest resolve-from and resolve-global. What do you think? I will create a PR with the solution listed below!
Expected Behavior
Current Behavior
Affected packages
Possible Solution
So, I took a look at
@commitlint/load
how it's loading the configuration. I noticed thatcosmiconfig
is used, so I started digging there. It turns out; it's pretty hard to resolve things like this. I would recommend using an external library to fix this. So far I found two libraries, both from Sindre Sorhus which should cover all of our needs; resolve-from and resolve-global (both MIT licensed).With this we can do this:
I've briefly talked with demurgos, from node-tooling slack, about this. And I agree with him that local should be resolved before global, so the order is intentional.
Steps to Reproduce (for bugs)
npm install -g commitlint commitlint-format-junit
echo 'foo: bar' | npx commitlint -o commitlint-format-junit
Your Environment
I'm running this from a docker container, so I wouldn't pollute my own global installations 😄If you want to use the same environment, spin it up with:
commitlint --version
git --version
node --version
The text was updated successfully, but these errors were encountered: