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
@commitlint/prompt-cli calls prompt from @commitlint/prompt without args (here)
@commitlint/prompt calls load from @commitlint/core without args (here)
@commitlint/core load 2nd param, options, defaults to {cwd: ''} (here)
@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?
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-cliwas no longer providing valid types when I hit tab.Below is the flow executed to load the config so you can see that none of the steps is providing options.cwd
@commitlint/prompt-clicalls prompt from@commitlint/promptwithout args (here)@commitlint/promptcalls load from@commitlint/corewithout args (here)@commitlint/coreload 2nd param, options, defaults to{cwd: ''}(here)@commitlint/coreload uses options.cwd to load the config (here)Since no options are provided to
@commitlint/coreload, then it uses defaults, and therefore no config is loaded as it tries to load usingoptions.cwdwhich is an empty string.After having detected this I was wondering why
@commitlint/cliis not having the same issue, and the answer is here, that as you can see it usesprocess.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/coreload toprocess.cwd()as follows:And indeed this worked.
Another alternative would be to pass
{cwd: process.cwd()}when prompt calls load...What do you think?