Skip to content

Commit

Permalink
chore: Update changelog script to respect code blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
kitten committed Mar 8, 2023
1 parent 4133d91 commit 272544a
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions scripts/changesets/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ const TRAILING_CHAR = /[.;:]$/g;
const listFormatter = new Intl.ListFormat('en-US');

const getSummaryLines = cs => {
const lines = cs.summary
.trim()
.split(/[\r\n]+/)
.map(l => l.trim())
.filter(Boolean);
const size = lines.length;
if (size > 0) {
lines[size - 1] = lines[size - 1]
.replace(TRAILING_CHAR, '');
let lines = cs.summary.trim().split(/\r?\n/);
if (!lines.some(line => /```/.test(line))) {
lines = lines.map(l => l.trim()).filter(Boolean);
const size = lines.length;
if (size > 0) {
lines[size - 1] = lines[size - 1]
.replace(TRAILING_CHAR, '');
}
}

return lines;
};

Expand Down Expand Up @@ -111,8 +109,11 @@ const changelogFunctions = {
str += `\n${futureLines.map(l => ` ${l}`).join('\n')}`;
}

if (user) {
const endsWithParagraph = /(?<=(?:[!;?.]|```) *)$/g;
if (user && !endsWithParagraph) {
str += `, by ${user}`;
} else {
str += `\nBy ${user}`;
}

if (pull || commit) {
Expand Down

0 comments on commit 272544a

Please sign in to comment.