Skip to content
This repository has been archived by the owner on Feb 5, 2018. It is now read-only.

Commit

Permalink
feat(mergeConfig): add defaultFinalizeContext
Browse files Browse the repository at this point in the history
Makes it possible to modify the result based on the default function.
  • Loading branch information
stevemao committed Apr 10, 2016
1 parent 35285bf commit b6f6f7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/merge-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -264,6 +264,9 @@ function mergeConfig(options, context, gitRawCommitsOpts, parserOpts, writerOpts
}

return context;
},
finalizeContext: function() {
return this.defaultFinalizeContext.apply(this, arguments);
}
},
config.writerOpts, {
Expand Down
12 changes: 11 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b6f6f7c

Please sign in to comment.