Skip to content

Commit

Permalink
call plugins functions during parseReleases
Browse files Browse the repository at this point in the history
  • Loading branch information
mansona committed Jul 1, 2022
1 parent f8bf54f commit 21c548b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/releases.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
const semver = require('semver')
const importCwd = require('import-cwd');
const { fetchCommits } = require('./commits')

const MERGE_COMMIT_PATTERN = /^Merge (remote-tracking )?branch '.+'/
const COMMIT_MESSAGE_PATTERN = /\n+([\S\s]+)/

const parseReleases = async (tags, options, onParsed) => {
let plugins = options.plugin.map(p => importCwd(`auto-changelog-${p}`));

const releases = await Promise.all(tags.map(async tag => {
const commits = await fetchCommits(tag.diff, options)
const merges = commits.filter(commit => commit.merge).map(commit => commit.merge)
const fixes = commits.filter(commit => commit.fixes).map(commit => ({ fixes: commit.fixes, commit }))

for (let plugin of plugins) {
if (plugin.processCommits) {
await plugin.processCommits(commits);
}

if (plugin.processMerges) {
await plugin.processMerges(merges);
}
}

const emptyRelease = merges.length === 0 && fixes.length === 0
const { message } = commits[0] || { message: null }
const breakingCount = commits.filter(c => c.breaking).length
Expand All @@ -26,7 +40,14 @@ const parseReleases = async (tags, options, onParsed) => {
merges,
fixes
}
}))
}))

for (let plugin of plugins) {
if (plugin.processReleases) {
await plugin.processReleases(releases);
}
}

return releases.filter(filterReleases(options))
}

Expand Down

0 comments on commit 21c548b

Please sign in to comment.