diff --git a/lib/src/Gren.js b/lib/src/Gren.js index 67d3cafe..e919ecfd 100644 --- a/lib/src/Gren.js +++ b/lib/src/Gren.js @@ -606,13 +606,16 @@ class Gren { * @return {string} */ _templateGroups(groups) { + const { groupPostProcessor } = this.options; + return Object.entries(groups).map(([key, value]) => { const heading = generate({ heading: key }, this.options.template.group); const body = value.join('\n'); + const content = heading + '\n' + body; - return heading + '\n' + body; + return groupPostProcessor ? groupPostProcessor(content) : content; }); } diff --git a/test/Gren.spec.js b/test/Gren.spec.js index b268b412..9b97b1ee 100644 --- a/test/Gren.spec.js +++ b/test/Gren.spec.js @@ -211,6 +211,22 @@ describe('Gren', () => { }; assert.deepEqual(gren._groupBy(normal), [`All\n${normal[0].title}`], 'The issue does not match any labels, and goes in the ... group'); }); + + it('Should format group using post formatter', () => { + const { normal, noLabel } = issues; + + gren.options.groupBy = { + 'Test:': ['enhancement'], + 'Others:': ['closed'] + }; + + gren.options.groupPostProcessor = (groupContent) => { + return groupContent.replace(0, groupContent.indexOf(':\n') + 3); + } + + assert.deepEqual(gren._groupBy(normal), [`Test:`], 'Passing one heading for one issue'); + assert.deepEqual(gren._groupBy(noLabel), [`Others:`], 'Group option is "label" with no labels'); + }); }); describe('_filterIssue', () => {
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies: