From 5798a7a5a162432b9521cefe567dac1adcfc53d7 Mon Sep 17 00:00:00 2001 From: El-Hussein Abdelraouf Date: Tue, 9 Aug 2022 13:06:02 +0200 Subject: [PATCH] add new --changelog option (#912) --- lib/cli.js | 1 + lib/config.js | 6 +++++- lib/index.js | 7 ++++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/cli.js b/lib/cli.js index d950ae21..cc7c6069 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -20,6 +20,7 @@ const helpText = `Release It! v${pkg.version} --only-version Prompt only for version, no further interaction -v --version Print release-it version number --release-version Print version number to be released + --changelog Print changelog for the version to be released -V --verbose Verbose output (user hooks output) -VV Extra verbose output (also internal commands output) diff --git a/lib/config.js b/lib/config.js index 0d8c3ef0..14fd5831 100644 --- a/lib/config.js +++ b/lib/config.js @@ -109,7 +109,7 @@ class Config { } get isCI() { - return Boolean(this.options.ci) || this.isReleaseVersion; + return Boolean(this.options.ci) || this.isReleaseVersion || this.isChangelog; } get isPromptOnlyVersion() { @@ -119,6 +119,10 @@ class Config { get isReleaseVersion() { return Boolean(this.options['release-version']); } + + get isChangelog() { + return Boolean(this.options['changelog']); + } } export default Config; diff --git a/lib/index.js b/lib/index.js index 2a2babd6..1949e985 100644 --- a/lib/index.js +++ b/lib/index.js @@ -78,7 +78,7 @@ const runTasks = async (opts, di) => { const action = config.isIncrement ? 'release' : 'update'; const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`; - if (!config.isReleaseVersion) { + if (!config.isReleaseVersion && !config.isChangelog) { log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`); log.preview({ title: 'changelog', text: changelog }); @@ -93,6 +93,11 @@ const runTasks = async (opts, di) => { process.exit(0); } + if (config.isChangelog) { + console.log(changelog); + process.exit(0); + } + if (version) { config.setContext(parseVersion(version));