Commitlint: Error when linting with config-lerna-scopes

Created on 9 Oct 2017  路  5Comments  路  Source: conventional-changelog/commitlint

When trying to lint a message with config-lerna-scopes, the following error is issued:

$ echo "chore(api): fix something in api's build" | npx commitlint
/Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/cli/cli.js:130
        throw err;
        ^

TypeError: Cannot read property 'map' of undefined
    at getPackages (/Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/config-lerna-scopes/index.js:13:3)
    at scope-enum (/Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/config-lerna-scopes/index.js:6:37)
    at /Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/core/lib/library/execute-rule.js:23:28
    at Promise (<anonymous>)
    at /Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/core/lib/library/execute-rule.js:21:26
    at Promise (<anonymous>)
    at exports.default (/Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/core/lib/library/execute-rule.js:14:9)
    at /Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/core/lib/load.js:109:44
    at Array.map (<anonymous>)
    at /Users/quentinroy/Workspace/reacolo/node_modules/@commitlint/core/lib/load.js:108:79

After investigation, it seems the plugin relies on lerna/lib/Repository#packages which does not exist anymore (at least with lerna 2.4.0)

bug

All 5 comments

Thanks for raising this, will investigate right away.

You may want to have a look at #88 which seems to solve the issue for me. Not sure how to thoroughly test it though.

Changes I added on top of the fix via #89:

  • move test-git to distinct package for reuse in config-lerna, core, potentially others
  • add npm.bootstrap helper to init a temp git repo and install via npm if a package.json is found
  • rewrite parts of config-lerna to allow for testing
  • unit test some config-lerna assumptions
  • test for .notThrows with lerna 2.4 and 2.0 specifically
  • load lerna from context.cwd || process.cwd (not plugged into core!)

Released the fix via 4.1.1. Thanks for your help!

Opened the follow-up to this at https://github.com/lerna/lerna/issues/1071

Was this page helpful?
0 / 5 - 0 ratings