Skip to content

fix: accept parser and writer options from conventional-changelog 7+ presets - #351

Open
SahinurDEV wants to merge 1 commit into
absolute-version:masterfrom
SahinurDEV:fix/accept-preset-parser-writer-keys
Open

SahinurDEV wants to merge 1 commit into
absolute-version:masterfrom
SahinurDEV:fix/accept-preset-parser-writer-keys

Conversation

@SahinurDEV

Copy link
Copy Markdown

Problem

Since v13, presets built on conventional-changelog 7+ (e.g. conventional-changelog-conventionalcommits's createPreset()) return their options as { commits, parser, writer, whatBump } instead of { parserOpts, writerOpts, ... }. When such a preset is used directly as the configuration (commit-and-tag-version --config ./src/index.js in a preset's own repo, as described in the issue), its parser and writer options are silently ignored, because commit-and-tag-version only reads parserOpts and writerOpts.

Cause

lib/lifecycles/bump.js and lib/lifecycles/changelog.js only pass args.parserOpts / args.writerOpts to conventional-changelog.

Fix

Following the suggestion in the issue thread to detect both kinds, accept parser and writer as aliases of parserOpts and writerOpts (new getParserOpts() / getWriterOpts() helpers in lib/preset-loader.js, used by the bump and changelog lifecycles). If both are given they are merged, with the existing parserOpts / writerOpts keys taking precedence, so existing configs behave exactly as before. The README's "Deeper customization" section mentions the aliases.

Tests

Added two CLI integration tests to test/esm-config.integration-test.js:

  • a .versionrc.js that returns createPreset({ types: [{ type: 'feat', section: 'Shiny Features' }] }): the changelog now uses the preset's writer (custom section name);
  • a config with parser: { noteKeywords: ['HEADS-UP'] }: the parser option is applied in the bump step (a HEADS-UP: note now gives a major bump).

Both fail without the change. npm test passes (13 files, 156 tests), plus lint and format:check.

Fixes #328

…presets

Presets built on conventional-changelog >= 7 return their options under
`parser` and `writer` instead of `parserOpts` and `writerOpts`, so a
preset used directly as the configuration (--config ./preset.js) had its
parser and writer options silently ignored. Accept both shapes, with the
legacy *Opts keys taking precedence.

Fixes absolute-version#328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using local preset via config arg in v13

1 participant