Repository navigation
fix: accept parser and writer options from conventional-changelog 7+ presets - #351
Open
SahinurDEV wants to merge 1 commit into
Open
SahinurDEV wants to merge 1 commit into
SahinurDEV wants to merge 1 commit into
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since v13, presets built on conventional-changelog 7+ (e.g.
conventional-changelog-conventionalcommits'screatePreset()) 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.jsin a preset's own repo, as described in the issue), its parser and writer options are silently ignored, because commit-and-tag-version only readsparserOptsandwriterOpts.Cause
lib/lifecycles/bump.jsandlib/lifecycles/changelog.jsonly passargs.parserOpts/args.writerOptsto conventional-changelog.Fix
Following the suggestion in the issue thread to detect both kinds, accept
parserandwriteras aliases ofparserOptsandwriterOpts(newgetParserOpts()/getWriterOpts()helpers inlib/preset-loader.js, used by the bump and changelog lifecycles). If both are given they are merged, with the existingparserOpts/writerOptskeys 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:.versionrc.jsthat returnscreatePreset({ types: [{ type: 'feat', section: 'Shiny Features' }] }): the changelog now uses the preset's writer (custom section name);parser: { noteKeywords: ['HEADS-UP'] }: the parser option is applied in the bump step (aHEADS-UP:note now gives a major bump).Both fail without the change.
npm testpasses (13 files, 156 tests), plus lint andformat:check.Fixes #328