Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/src/Gren.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
}

Expand Down
16 changes: 16 additions & 0 deletions test/Gren.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

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:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy