Skip to content

Configuration is not loaded in prompt-cli #100

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

Closed
mgtitimoli opened this issue Oct 25, 2017 · 3 comments
Closed

Configuration is not loaded in prompt-cli #100

mgtitimoli opened this issue Oct 25, 2017 · 3 comments

Comments

@mgtitimoli
Copy link

mgtitimoli commented Oct 25, 2017

Hi,

Before going forward I want to thank you, I have been using the suite (config-angular, cli, prompt-cli) for a long time, it's amazing, great work!

Today I finally decided to update to latest (4.2.0), and then at the time to commit, I noticed prompt-cli was no longer providing valid types when I hit tab.

TL;DR config is not loaded because no options.cwd is provided to @commitlint/core load and defaults to "" (empty string) so rules are not loaded and therefore there is no info to autocomplete.

Below is the flow executed to load the config so you can see that none of the steps is providing options.cwd

  1. @commitlint/prompt-cli calls prompt from @commitlint/prompt without args (here)
  2. @commitlint/prompt calls load from @commitlint/core without args (here)
  3. @commitlint/core load 2nd param, options, defaults to {cwd: ''} (here)
  4. @commitlint/core load uses options.cwd to load the config (here)

Since no options are provided to @commitlint/core load, then it uses defaults, and therefore no config is loaded as it tries to load using options.cwd which is an empty string.

After having detected this I was wondering why @commitlint/cli is not having the same issue, and the answer is here, that as you can see it uses process.cwd() as the default instead of an empty string.

So finally and as an attempt to solve the issue I replicated the logic in @commitlint/cli, so I set options.cwd default in @commitlint/core load to process.cwd() as follows:

export default async (seed = {}, options = {cwd: process.cwd()}) => {
  // ...
}

And indeed this worked.

Another alternative would be to pass {cwd: process.cwd()} when prompt calls load...

What do you think?

@marionebl marionebl added the bug label Oct 26, 2017
@marionebl
Copy link
Contributor

Thanks for catching this and the analysis/debugging.

You are right - replacing options = {cwd: ''} with {cwd: process.cwd()} is the correct fix for this.

Would you mind contributing the fix and adding a test case to core that covers this?

@marionebl
Copy link
Contributor

marionebl commented Oct 26, 2017

Fixed via release 4.2.2

@mgtitimoli
Copy link
Author

I've just seen your message, thanks @marionebl!

bpedersen pushed a commit to bpedersen/commitlint that referenced this issue Oct 15, 2019
…-changelog#100 (conventional-changelog#117)

* chore: refactoring version page

* refactor: migrate version page to hooks

* refactor: Version page better imports

* fix: conventional-changelog#100 render not found on click item

* test: add test for version page

* chore: update mocks

* test: add scenario for not found package

* chore: fix wrong mock path

* chore: update mock

* chore: add todo list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants