Skip to content

--config treats absolute path wrongly #647

Closed
@kirillgroshkov

Description

@kirillgroshkov

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

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions