Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions .release-it.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
const fs = require("fs");
const path = require("path");

const commits_template = fs
.readFileSync(
path.resolve(__dirname, "release-it", "conventional-changelog-commit.hbs"),
)
.toString();
const commitPartial = require("./release-it/conventional-changelog-commit.js");

module.exports = {
npm: {
Expand Down Expand Up @@ -47,11 +40,14 @@ module.exports = {
],
},
writerOpts: {
commitPartial: commits_template,
commitPartial,
},
},
},
hooks: {
// Format the changelog after it is written, before Git stages it.
"after:@release-it/conventional-changelog:beforeRelease":
"npx prettier --write CHANGES.md",
// Run `make bundle` after the version is bumped to get a build with
// the new version number comment in the entry scripts.
// Use the make target which does a check to not build if the package
Expand Down
72 changes: 0 additions & 72 deletions release-it/conventional-changelog-commit.hbs

This file was deleted.

45 changes: 45 additions & 0 deletions release-it/conventional-changelog-commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// The preset adds the list marker and indents continuation lines.
module.exports = function commitPartial(context, commit) {
const repoUrl = context.repository
? [context.host, context.owner, context.repository].filter(Boolean).join("/")
: context.repoUrl;
const summary = [
commit.scope && `**${commit.scope}:**`,
commit.subject || commit.header,
commit.hash &&
(context.linkReferences
? `([${commit.shortHash}](${repoUrl}/${context.commit}/${commit.hash}))`
: commit.hash),
]
.filter(Boolean)
.join(" ");

const references = (commit.references || []).map((reference) => {
const label = `${reference.owner ? `${reference.owner}/` : ""}${reference.repository || ""}#${reference.issue}`;
if (!context.linkReferences) {
return label;
}

const referenceUrl = context.repository
? [
context.host,
reference.repository
? reference.owner || context.owner
: context.owner,
reference.repository || context.repository,
]
.filter(Boolean)
.join("/")
: context.repoUrl;
return `[${label}](${referenceUrl}/${context.issue}/${reference.issue})`;
});

return [
summary,
commit.body,
commit.footer,
references.length && `closes ${references.join(" ")}`,
]
.filter(Boolean)
.join("\n\n");
};