mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Sorted the release changelog by emoji
no issue
This commit is contained in:
parent
3bd4d736d8
commit
45bd9ec37f
2 changed files with 19 additions and 1 deletions
|
@ -22,6 +22,7 @@ function getFinalChangelog(options) {
|
||||||
|
|
||||||
if (filterEmojiCommits) {
|
if (filterEmojiCommits) {
|
||||||
changelog = localUtils.filterEmojiCommits(changelog);
|
changelog = localUtils.filterEmojiCommits(changelog);
|
||||||
|
changelog.sortByEmoji();
|
||||||
}
|
}
|
||||||
|
|
||||||
finalChangelog = finalChangelog.concat(changelog);
|
finalChangelog = finalChangelog.concat(changelog);
|
||||||
|
|
|
@ -12,6 +12,8 @@ const getCommitMessageFromLine = line => line
|
||||||
.replace(hash, '')
|
.replace(hash, '')
|
||||||
.replace(url, '');
|
.replace(url, '');
|
||||||
|
|
||||||
|
const emojiOrder = ['💡', '🐛', '🎨', '💄', '✨'];
|
||||||
|
|
||||||
module.exports.filterEmojiCommits = (content) => {
|
module.exports.filterEmojiCommits = (content) => {
|
||||||
if (!_.isArray(content)) {
|
if (!_.isArray(content)) {
|
||||||
throw new Error('Expected array of strings.');
|
throw new Error('Expected array of strings.');
|
||||||
|
@ -19,7 +21,6 @@ module.exports.filterEmojiCommits = (content) => {
|
||||||
|
|
||||||
return content.reduce((emojiLines, currentLine) => {
|
return content.reduce((emojiLines, currentLine) => {
|
||||||
const commitMessage = getCommitMessageFromLine(currentLine);
|
const commitMessage = getCommitMessageFromLine(currentLine);
|
||||||
|
|
||||||
const match = emojiRegex().exec(commitMessage);
|
const match = emojiRegex().exec(commitMessage);
|
||||||
|
|
||||||
if (match && match.index === 0) {
|
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) => {
|
module.exports.checkMissingOptions = (options = {}, ...requiredFields) => {
|
||||||
const missing = requiredFields.filter((requiredField) => {
|
const missing = requiredFields.filter((requiredField) => {
|
||||||
return !_.get(options, requiredField);
|
return !_.get(options, requiredField);
|
||||||
|
|
Loading…
Add table
Reference in a new issue