From b6f6f7c01e586346b7bd52bd1b2ebeb8e9dcb0b0 Mon Sep 17 00:00:00 2001 From: Steve Mao Date: Sun, 10 Apr 2016 22:17:42 +1000 Subject: [PATCH] feat(mergeConfig): add defaultFinalizeContext Makes it possible to modify the result based on the default function. --- lib/merge-config.js | 5 ++++- readme.md | 12 +++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/merge-config.js b/lib/merge-config.js index b6f0bd5..60aee2a 100644 --- a/lib/merge-config.js +++ b/lib/merge-config.js @@ -219,7 +219,7 @@ function mergeConfig(options, context, gitRawCommitsOpts, parserOpts, writerOpts } writerOpts = _.assign({ - finalizeContext: function(context, writerOpts, filteredCommits, keyCommit, originalCommits) { + defaultFinalizeContext: function(context, writerOpts, filteredCommits, keyCommit, originalCommits) { var firstCommit = originalCommits[0]; var lastCommit = originalCommits[originalCommits.length - 1]; var firstCommitHash = firstCommit ? firstCommit.hash : null; @@ -264,6 +264,9 @@ function mergeConfig(options, context, gitRawCommitsOpts, parserOpts, writerOpts } return context; + }, + finalizeContext: function() { + return this.defaultFinalizeContext.apply(this, arguments); } }, config.writerOpts, { diff --git a/readme.md b/readme.md index 813008f..909d118 100644 --- a/readme.md +++ b/readme.md @@ -188,7 +188,17 @@ See the [conventional-changelog-writer](https://github.com/conventional-changelo Finalize context is used for generating above context. -**NOTE:** If you overwrite this value the above context defaults will be gone. +**NOTE:** If you overwrite this value the above context defaults will be gone. If you want to modify the result based on the default function, you could do: + +```js +finalizeContext: function() { + var newContext = this.defaultFinalizeContext.apply(this, arguments); + + // Modify newContext + + return newContext; +} +``` ##### reverse