Skip to content

Allow running globally installed commitlint and config-angular from anywhere #126

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
2 of 4 tasks
zanona opened this issue Nov 18, 2017 · 5 comments
Closed
2 of 4 tasks
Labels

Comments

@zanona
Copy link

zanona commented Nov 18, 2017

Expected Behavior

I expect to run echo 'hello world' | commitlint under any directory where that will be analysed against the config-angular preset which was globally installed.

Current Behavior

  $  echo 'hello' | commitlint
/usr/local/lib/node_modules/@commitlint/cli/lib/cli.js:67
		throw err;
		^

Error: Cannot find module '@commitlint/config-angular'
    at Function.Module._resolveFilename (module.js:527:15)
    at resolveFileName (/usr/local/lib/node_modules/@commitlint/cli/node_modules/resolve-from/index.js:17:39)
    at resolveFrom (/usr/local/lib/node_modules/@commitlint/cli/node_modules/resolve-from/index.js:31:9)
    at module.exports (/usr/local/lib/node_modules/@commitlint/cli/node_modules/resolve-from/index.js:34:41)
    at resolveId (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/library/resolve-extends.js:108:35)
    at resolveConfig (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/library/resolve-extends.js:99:18)
    at /usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/library/resolve-extends.js:50:18
    at Array.reduce (<anonymous>)
    at loadExtends (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/library/resolve-extends.js:48:32)
    at resolveExtends (/usr/local/lib/node_modules/@commitlint/cli/node_modules/@commitlint/core/lib/library/resolve-extends.js:31:17)

Affected packages

  • cli
  • core
  • prompt
  • config-angular

Possible Solution

Follow Less or ESLint which offer options to run their plugins also installed globally.

Steps to Reproduce (for bugs)

  1. npm install -g @commitlint/cli @commitlint/config-angular
  2. echo "module.exports = {extends: ['@commitlint/config-angular']}" > ~/commitlint.config.js
  3. echo 'hello world' | commitlint
commitlint.config.js
module.exports = {extends: ['@commitlint/config-angular']}

Context

Being able to run commintlint globally without the need to have a config file on every repo I want to run it.

Your Environment

Executable Version
commitlint --version 5.0.0
git --version 2.13.5
node --version v8.7.0
@marionebl marionebl added the bug label Nov 18, 2017
@marionebl
Copy link
Contributor

Just reproduced it. This should work, I guess this is broken by our resolve-from usage or inside resolve-from. Needs a bit more investigation.

marionebl added a commit that referenced this issue Nov 19, 2017
* chore: avoid gpg password prompt

* test(core): add failing test case for global extends resolving

* fix(core): fall back to globally installed config if available #126

* test: use cwd correctly for git config

* test: improve testability of global fallback

* fix(core): ensure resolve-globals is detected as dependency

* fix: use more recent import-fresh

* fix: fall back to require-uncached

Avoid sindresorhus/import-fresh#6 for the time being

* fix: pull in patch releases
@marionebl
Copy link
Contributor

Steps to reproduce create this result as of 5.0.1:

npm install -g @commitlint/cli @commitlint/config-angular
echo "module.exports = {extends: ['@commitlint/config-angular']}" > ~/commitlint.config.js
echo 'hello world' | commitlint
⧗   input: hello world
✖   message may not be empty [subject-empty]
✖   type may not be empty [type-empty]
✖   found 2 problems, 0 warnings

echo 'test: some message' | commitlint
⧗   input: test: hello world
✔   found 0 problems, 0 warnings

@zanona
Copy link
Author

zanona commented Nov 19, 2017

Awesome! Thanks!

@kqvanity
Copy link

@marionebl I currently manually copy the config file from the home dir to each separate repo dir. Can commitlint be configured to use the former right away?

@escapedcat
Copy link
Member

@xquilt does this work?:
#613 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants