Skip to content

Commit

Permalink
feat: add the option to silent the logging output
Browse files Browse the repository at this point in the history
This commit adds a 'silent' option that disables any logging output.
This is particularly useful when running with '--dry-run' in order to capture
only the release notes output from Semantic Versioning without the logging
messages.
  • Loading branch information
diogokiss committed Sep 4, 2023
1 parent ffb07ef commit fff5466
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Usage:
.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("silent", { describe: "Disable logging output.", 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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export default async (cliOptions = {}, { cwd = process.cwd(), env = process.env,
stderr: stderr || process.stderr,
envCi: envCi({ env, cwd }),
};
context.logger = getLogger(context);
context.logger = getLogger(context, cliOptions.silent);
context.logger.log(`Running ${pkg.name} version ${pkg.version}`);
try {
const { plugins, options } = await getConfig(context, cliOptions);
Expand Down
1 change: 1 addition & 0 deletions lib/get-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ export default async (context, cliOptions) => {
repositoryUrl: (await pkgRepoUrl({ normalize: false, cwd })) || (await repoUrl({ cwd, env })),
tagFormat: `v\${version}`,
marked: true,
silent: false,
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
Expand Down
10 changes: 6 additions & 4 deletions lib/get-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import figures from "figures";

const { Signale } = signale;

export default ({ stdout, stderr }) =>
new Signale({
export default (context, disabled = false) => {
const { stdout, stderr } = context;
return new Signale({
config: { displayTimestamp: true, underlineMessage: false, displayLabel: false },
disabled: false,
disabled: disabled,
interactive: false,
scope: "semantic-release",
stream: [stdout],
Expand All @@ -15,4 +16,5 @@ export default ({ stdout, stderr }) =>
log: { badge: figures.info, color: "magenta", label: "", stream: [stdout] },
success: { badge: figures.tick, color: "green", label: "", stream: [stdout] },
},
});
})
};

0 comments on commit fff5466

Please sign in to comment.