Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(release-notes): running unemojify on release notes #9535

Merged
merged 1 commit into from Apr 14, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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;
}