| 162 | }; |
| 163 | |
| 164 | function formatMarkdown(tag, prevTag, sections, { plain }) { |
| 165 | const lines = [ |
| 166 | flags.changelogOnly |
| 167 | ? "" |
| 168 | : `Changes since [${prevTag}](https://github.com/${owner}/${repo}/releases/tag/${prevTag})`, |
| 169 | "", |
| 170 | ]; |
| 171 | |
| 172 | for (const [type, list] of Object.entries(sections)) { |
| 173 | if (list.length === 0) continue; |
| 174 | const header = plain |
| 175 | ? `## ${type}` |
| 176 | : `## ${emojis[type]}${type[0].toUpperCase() + type.slice(1)}`; |
| 177 | lines.push(header, "", list.join("\n"), ""); |
| 178 | } |
| 179 | |
| 180 | // Compact single-line mode for super small output |
| 181 | // if (plain) { |
| 182 | // const compact = Object.entries(sections) |
| 183 | // .filter(([_, list]) => list.length) |
| 184 | // .map(([type, list]) => `${type.toUpperCase()}: ${list.length} commits`) |
| 185 | // .join(" | "); |
| 186 | // lines.push(`\n_Summary: ${compact}_`); |
| 187 | // } |
| 188 | |
| 189 | return lines.join("\n"); |
| 190 | } |
| 191 | |
| 192 | function formatJSON(tag, prevTag, sections, plain = true) { |
| 193 | const lines = [ |