Skip to content

Consider using npm module name instead of relative path in adapter config generated by commitizen init #469

Description

@mickdekkers

The setup instructions in the readme use the module name of the adapter (i.e. cz-conventional-changelog), but the actual config generated by commitizen init uses a relative path to the module:

let commitizenAdapterConfig = {
config: {
commitizen: {
path: `./node_modules/${adapterNpmName}`
}
}
};

According to the readme:

commitizen.path is resolved via require.resolve and supports

  • npm modules
  • directories relative to process.cwd() containing an index.js file
  • file base names relative to process.cwd() with js extension
  • full relative file names
  • absolute paths.

One downside of using a relative path is that developers cannot use their global commitizen install to create a commit if they have not yet run npm install in the repo, because this results in an error:

Error: Could not resolve /Users/mickdekkers/Projects/foo/node_modules/cz-conventional-changelog.
Cannot find module '/Users/mickdekkers/Projects/foo/node_modules/cz-conventional-changelog'

This change should fix the issue, although I'm not sure whether it would be considered breaking:

let commitizenAdapterConfig = { 
   config: { 
     commitizen: { 
-      path: `./node_modules/${adapterNpmName}`
+      path: adapterNpmName
     } 
   } 
 }; 

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions