Skip to content

Commit

Permalink
Update format
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore committed Feb 7, 2024
1 parent 3e8bc9a commit cd51e8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/index.mjs

Large diffs are not rendered by default.

28 changes: 20 additions & 8 deletions src/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ function isSimpleIconsDataFile(path) {
}

function prNumbersToString(prNumbers) {
return prNumbers.map((prNumber) => `#${prNumber}`).join(' ');
return prNumbers.map((prNumber) => `#${prNumber}`).join(', ');
}

function authorsToString(authors) {
return authors.map((author) => `@${author}`).join(', ');
}

// GitHub API
Expand Down Expand Up @@ -277,7 +281,7 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
author: file.author,
authors: [file.author],
},
];
} else if (isIconFile(file.path) && file.status === STATUS_MODIFIED) {
Expand All @@ -292,7 +296,7 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
author: file.author,
authors: [file.author],
},
];
} else if (isIconFile(file.path) && file.status === STATUS_REMOVED) {
Expand All @@ -306,7 +310,7 @@ async function getChangesFromFile(core, file, client, context, id) {
name: he.decode(svgTitleMatch[1]),
path: file.path,
prNumbers: [file.prNumber],
author: file.author,
authors: [file.author],
},
];
} else if (isSimpleIconsDataFile(file.path)) {
Expand Down Expand Up @@ -338,7 +342,7 @@ async function getChangesFromFile(core, file, client, context, id) {
changeType: CHANGE_TYPE_UPDATE,
name: name,
prNumbers: [file.prNumber],
author: file.author,
authors: [file.author],
});
}

Expand All @@ -360,6 +364,7 @@ function filterDuplicates(newIcons, updatedIcons, removedIcons) {
for (let updatedIcon of updatedIcons) {
if (updatedIcon.name === newIcon.name) {
newIcon.prNumbers.push(...updatedIcon.prNumbers);
newIcons.authors.push(...updatedIcon.authors);
removeFromUpdated.push(updatedIcon);
}
}
Expand Down Expand Up @@ -413,7 +418,11 @@ function filterDuplicates(newIcons, updatedIcons, removedIcons) {
const otherPrNumbers = otherIcon.prNumbers.filter(
(prNumber) => !updatedIcon.prNumbers.includes(prNumber),
);
const otherAuthors = otherIcon.authors.filter(
(author) => !updatedIcon.authors.includes(author),
);
updatedIcon.prNumbers.push(...otherPrNumbers);
updatedIcon.authors.push(...otherAuthors);
removeFromUpdated.push(otherIcon);
}
}
Expand Down Expand Up @@ -491,23 +500,26 @@ function createReleaseNotes(newVersion, newIcons, updatedIcons, removedIcons) {
releaseNotes += '\n# New Icons\n\n';
for (let newIcon of newIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(newIcon.prNumbers);
releaseNotes += `- ${newIcon.name} (${prs}) (@${newIcon.author})\n`;
const authors = authorsToString(newIcon.authors);
releaseNotes += `- ${newIcon.name} (${prs}) (${authors})\n`;
}
}

if (updatedIcons.length > 0) {
releaseNotes += '\n# Updated Icons\n\n';
for (let updatedIcon of updatedIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(updatedIcon.prNumbers);
releaseNotes += `- ${updatedIcon.name} (${prs}) (@${updatedIcon.author})\n`;
const authors = authorsToString(updatedIcon.authors);
releaseNotes += `- ${updatedIcon.name} (${prs}) (${authors})\n`;
}
}

if (removedIcons.length > 0) {
releaseNotes += '\n# Removed Icons\n\n';
for (let removedIcon of removedIcons.sort(sortAlphabetically)) {
const prs = prNumbersToString(removedIcon.prNumbers);
releaseNotes += `- ${removedIcon.name} (${prs}) (@${removedIcon.author})\n`;
const authors = authorsToString(removedIcon.authors);
releaseNotes += `- ${removedIcon.name} (${prs}) (${authors})\n`;
}
}

Expand Down

0 comments on commit cd51e8c

Please sign in to comment.