conventional-changelog-writer
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -36,2 +36,5 @@ 'use strict'; | ||
}, | ||
finalizeContext: function(context) { | ||
return context; | ||
}, | ||
reverse: false, | ||
@@ -38,0 +41,0 @@ includeDetails: false, |
@@ -159,13 +159,15 @@ 'use strict'; | ||
var mergedContext = _.merge({}, context, keyCommit, getExtraContext(commits, notes, options)); | ||
context = _.merge({}, context, keyCommit, getExtraContext(commits, notes, options)); | ||
if (keyCommit && keyCommit.committerDate) { | ||
mergedContext.date = keyCommit.committerDate; | ||
context.date = keyCommit.committerDate; | ||
} | ||
if (mergedContext.version) { | ||
mergedContext.isPatch = context.isPatch || semver.patch(mergedContext.version) !== 0; | ||
if (context.version) { | ||
context.isPatch = context.isPatch || semver.patch(context.version) !== 0; | ||
} | ||
return compiled(mergedContext); | ||
context = options.finalizeContext(context, options, commits, keyCommit); | ||
return compiled(context); | ||
} | ||
@@ -172,0 +174,0 @@ |
{ | ||
"name": "conventional-changelog-writer", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Write logs based on conventional commits and templates", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/stevemao/conventional-changelog-writer", |
@@ -197,2 +197,24 @@ # [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage Status][coveralls-image]][coveralls-url] | ||
##### finalizeContext | ||
Type: `function` Default: pass through | ||
###### finalizeContext(context, options, commits, keyCommit) | ||
####### context | ||
The generated context based on original input `context` and `options`. | ||
####### options | ||
Normalized options. | ||
####### commits | ||
Filtered commits from your git metadata. | ||
####### keyCommit | ||
The commit that triggers to generate the log. | ||
##### reverse | ||
@@ -255,3 +277,3 @@ | ||
Basically you can make your own templates and define all your template variables. This module can iterate the commits and compile them. For more details, please checkout [handlebars](http://handlebarsjs.com) and the source code of this module. | ||
Basically you can make your own templates and define all your template context. Extra context are based on commits from upstream and `options`. For more details, please checkout [handlebars](http://handlebarsjs.com) and the source code of this module. | ||
@@ -258,0 +280,0 @@ |
@@ -548,3 +548,6 @@ 'use strict'; | ||
var log = util.generate({ | ||
mainTemplate: '{{whatever}}' | ||
mainTemplate: '{{whatever}}', | ||
finalizeContext: function(context) { | ||
return context; | ||
} | ||
}, [], { | ||
@@ -561,3 +564,6 @@ whatever: 'a' | ||
var log = util.generate({ | ||
mainTemplate: '{{whatever}}' | ||
mainTemplate: '{{whatever}}', | ||
finalizeContext: function(context) { | ||
return context; | ||
} | ||
}, [], [], { | ||
@@ -573,3 +579,6 @@ whatever: '`a`' | ||
mainTemplate: '{{#each commitGroups}}{{commits.length}}{{#each commits}}{{header}}{{/each}}{{/each}}{{#each noteGroups}}{{title}}{{#each notes}}{{this}}{{/each}}{{/each}}', | ||
ignoreReverted: true | ||
ignoreReverted: true, | ||
finalizeContext: function(context) { | ||
return context; | ||
} | ||
}, [{ | ||
@@ -637,3 +646,17 @@ header: 'revert: feat(): amazing new module\n', | ||
}); | ||
it('should finalize context', function() { | ||
var log = util.generate({ | ||
mainTemplate: '{{whatever}} {{somethingExtra}}', | ||
finalizeContext: function(context) { | ||
context.somethingExtra = 'oh'; | ||
return context; | ||
} | ||
}, [], [], { | ||
whatever: '`a`' | ||
}); | ||
expect(log).to.equal('`a` oh'); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72231
1792
350