Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cli): add new --changelog option #912

Merged
merged 1 commit into from Aug 9, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/cli.js
Expand Up @@ -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)

Expand Down
6 changes: 5 additions & 1 deletion lib/config.js
Expand Up @@ -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() {
Expand All @@ -119,6 +119,10 @@ class Config {
get isReleaseVersion() {
return Boolean(this.options['release-version']);
}

get isChangelog() {
return Boolean(this.options['changelog']);
}
}

export default Config;
7 changes: 6 additions & 1 deletion lib/index.js
Expand Up @@ -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 });
Expand All @@ -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));

Expand Down