Skip to content

Commit

Permalink
feat: make printing Markdown to the Terminal optional
Browse files Browse the repository at this point in the history
This commit adds a new configuration option called 'marked'.
When set to true, the output of Semantic Release would print Markdown to the
terminal, whenever supported, using the 'marked-terminal' library as usual.

https://www.npmjs.com/package/marked-terminal

When set to false, the output will be printed in plain text.
This feature is particularly useful when the output or the command will be
consumed by another Markdown renderer, like GitHub.

This addresses the following issue.
semantic-release#2191
  • Loading branch information
diogokiss committed Sep 4, 2023
1 parent 19c0965 commit 330006a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Usage:
.option("p", { alias: "plugins", describe: "Plugins", ...stringList, group: "Options" })
.option("e", { alias: "extends", describe: "Shareable configurations", ...stringList, group: "Options" })
.option("ci", { describe: "Toggle CI verifications", type: "boolean", group: "Options" })
.option("marked", { describe: "Enable printing Markdown to the Terminal", type: "boolean", group: "Options" })
.option("verify-conditions", { ...stringList, group: "Plugins" })
.option("analyze-commits", { type: "string", group: "Plugins" })
.option("verify-release", { ...stringList, group: "Plugins" })
Expand Down
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,12 @@ async function run(context, plugins) {
if (options.dryRun) {
logger.log(`Release note for version ${nextRelease.version}:`);
if (nextRelease.notes) {
context.stdout.write(await terminalOutput(nextRelease.notes));
if (options.marked) {
context.stdout.write(await terminalOutput(nextRelease.notes));
}
else {
context.stdout.write(nextRelease.notes);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export default async (context, cliOptions) => {
],
repositoryUrl: (await pkgRepoUrl({ normalize: false, cwd })) || (await repoUrl({ cwd, env })),
tagFormat: `v\${version}`,
marked: true,
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down

0 comments on commit 330006a

Please sign in to comment.