Commitlint: --config treats absolute path wrongly

Created on 8 May 2019  路  3Comments  路  Source: conventional-changelog/commitlint

Bug only happens after recent update (from @commitlint/[email protected] to @commitlint/[email protected]).

Before update: absolute paths to --config was treated properly (as absolute paths).

After update: absolute path in --config is treated as relative, so process.cwd() gets prepended to it and path becomes invalid, with error like this:

commitlint --config /Users/kirill/Idea/js-lib/node_modules/@naturalcycles/dev-lib/cfg/commitlint.config.js

/Users/kirill/Idea/js-lib/node_modules/@commitlint/cli/lib/cli.js:114
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/Users/kirill/Idea/js-lib/Users/kirill/Idea/js-lib/node_modules/@naturalcycles/dev-lib/cfg/commitlint.config.js'

I was running it from cwd of /Users/kirill/Idea/js-lib (as seen in the log above).

Affected packages

  • [x] cli
  • [ ] core
  • [ ] prompt
  • [ ] config-angular

Steps to Reproduce (for bugs)


  1. commitlint --config /Users/user/commitlist.config.js
  2. See that it resolved wrongly, like:
Error: ENOENT: no such file or directory, open '/Users/kirill/Idea/js-lib/Users/kirill/Idea/js-lib/node_modules/@naturalcycles/dev-lib/cfg/commitlint.config.js'

Your Environment

| Executable | Version |
| ---: | :--- |
| commitlint --version | VERSION |
7.6.0
| git --version | VERSION |
git version 2.20.1 (Apple Git-117)
| node --version | VERSION |
v10.15.3

bug

Most helpful comment

Fixed and released via @commitlint/[email protected]

All 3 comments

Found the commit that probably introduced this issue: https://github.com/conventional-changelog/commitlint/pull/605/files#diff-6d0443e2b1ca53a84781bf18785f8f46R91

Fixed and released via @commitlint/[email protected]

thanks!

Was this page helpful?
0 / 5 - 0 ratings