mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 19:33:02 +03:00
Sorted the release changelog by emoji
no issue
This commit is contained in:
parent
3bd4d736d8
commit
45bd9ec37f
@ -22,6 +22,7 @@ function getFinalChangelog(options) {
|
||||
|
||||
if (filterEmojiCommits) {
|
||||
changelog = localUtils.filterEmojiCommits(changelog);
|
||||
changelog.sortByEmoji();
|
||||
}
|
||||
|
||||
finalChangelog = finalChangelog.concat(changelog);
|
||||
|
@ -12,6 +12,8 @@ const getCommitMessageFromLine = line => line
|
||||
.replace(hash, '')
|
||||
.replace(url, '');
|
||||
|
||||
const emojiOrder = ['💡', '🐛', '🎨', '💄', '✨'];
|
||||
|
||||
module.exports.filterEmojiCommits = (content) => {
|
||||
if (!_.isArray(content)) {
|
||||
throw new Error('Expected array of strings.');
|
||||
@ -19,7 +21,6 @@ module.exports.filterEmojiCommits = (content) => {
|
||||
|
||||
return content.reduce((emojiLines, currentLine) => {
|
||||
const commitMessage = getCommitMessageFromLine(currentLine);
|
||||
|
||||
const match = emojiRegex().exec(commitMessage);
|
||||
|
||||
if (match && match.index === 0) {
|
||||
@ -30,6 +31,22 @@ module.exports.filterEmojiCommits = (content) => {
|
||||
}, []);
|
||||
};
|
||||
|
||||
module.exports.sortByEmoji = (content) => {
|
||||
if (!_.isArray(content)) {
|
||||
throw new Error('Expected array of strings.');
|
||||
}
|
||||
|
||||
content.sort((a, b) => {
|
||||
let firstEmoji = [...a][2];
|
||||
let secondEmoji = [...b][2];
|
||||
|
||||
let firstEmojiIndex = _.indexOf(emojiOrder, firstEmoji);
|
||||
let secondEmojiIndex = _.indexOf(emojiOrder, secondEmoji);
|
||||
|
||||
return secondEmojiIndex - firstEmojiIndex;
|
||||
});
|
||||
};
|
||||
|
||||
module.exports.checkMissingOptions = (options = {}, ...requiredFields) => {
|
||||
const missing = requiredFields.filter((requiredField) => {
|
||||
return !_.get(options, requiredField);
|
||||
|
Loading…
Reference in New Issue
Block a user