Skip to content

Commit

Permalink
feat(release-notes) running unemojify on release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
lucavb committed Apr 13, 2021
1 parent dd26fcf commit 3033d91
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
22 changes: 22 additions & 0 deletions lib/util/emoji.spec.ts
@@ -0,0 +1,22 @@
import { getName } from '../../test/util';
import { setEmojiConfig, unemojify } from './emoji';

describe(getName(__filename), () => {
it('strips emojis when the config has been set accordingly', () => {
const emoji = '🚀💎';
const otherText = 'regular text';
const text = `${emoji} ${otherText}`;
setEmojiConfig({ unicodeEmoji: false });
const result = unemojify(text);
expect(result).not.toContain(emoji);
});

it('does not strip emojis when the config demands it', () => {
const emoji = '🚀💎';
const otherText = 'regular text';
const text = `${emoji} ${otherText}`;
setEmojiConfig({ unicodeEmoji: true });
const result = unemojify(text);
expect(result).toEqual(text);
});
});
4 changes: 4 additions & 0 deletions lib/util/emoji.ts
Expand Up @@ -10,3 +10,7 @@ export function setEmojiConfig(_config: RenovateConfig): void {
export function emojify(text: string): string {
return unicodeEmoji ? emoji.emojify(text) : text;
}

export function unemojify(text: string): string {
return unicodeEmoji ? text : emoji.unemojify(text);
}
3 changes: 3 additions & 0 deletions lib/workers/pr/body/changelogs.ts
@@ -1,3 +1,4 @@
import { unemojify } from '../../../util/emoji';
import { sanitizeMarkdown } from '../../../util/markdown';
import * as template from '../../../util/template';
import type { BranchConfig } from '../../types';
Expand All @@ -13,5 +14,7 @@ export function getChangelogs(config: BranchConfig): string {
'\n\n---\n\n' + template.compile(releaseNotesHbs, config, false) + '\n\n';
releaseNotes = releaseNotes.replace(/### \[`vv/g, '### [`v');
releaseNotes = sanitizeMarkdown(releaseNotes);
releaseNotes = unemojify(releaseNotes);

return releaseNotes;
}

0 comments on commit 3033d91

Please sign in to comment.