diff --git a/lib/index.js b/lib/index.js index 20aca242..108af128 100644 --- a/lib/index.js +++ b/lib/index.js @@ -15,7 +15,7 @@ const runTasks = async (opts, di) => { container.config = container.config || new Config(opts); const { config } = container; - const { isCI, isVerbose, verbosityLevel, isDryRun } = config; + const { isCI, isVerbose, verbosityLevel, isDryRun, isChangelog, isReleaseVersion } = config; container.log = container.log || new Logger({ isCI, isVerbose, verbosityLevel, isDryRun }); container.spinner = container.spinner || new Spinner({ container, config }); @@ -62,6 +62,11 @@ const runTasks = async (opts, di) => { const latestVersion = (await reduceUntil(plugins, plugin => plugin.getLatestVersion())) || '0.0.0'; const changelog = await reduceUntil(plugins, plugin => plugin.getChangelog(latestVersion)); + if (isChangelog) { + console.log(changelog); + process.exit(0); + } + const incrementBase = { latestVersion, increment, isPreRelease, preReleaseId }; let version; @@ -74,8 +79,12 @@ const runTasks = async (opts, di) => { config.setContext({ name, latestVersion, version, changelog }); - const action = config.isIncrement ? 'release' : 'update'; - const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`; + if (!isReleaseVersion) { + const action = config.isIncrement ? 'release' : 'update'; + const suffix = version && config.isIncrement ? `${latestVersion}...${version}` : `currently at ${latestVersion}`; + log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`); + log.preview({ title: 'changelog', text: changelog }); + } if (config.isIncrement) { version = version || (await reduceUntil(plugins, plugin => plugin.getIncrementedVersion(incrementBase))); @@ -83,21 +92,13 @@ const runTasks = async (opts, di) => { if (!version) { log.obtrusive(`No new version to release`); - } else if (!config.isReleaseVersion && !config.isChangelog) { - log.obtrusive(`🚀 Let's ${action} ${name} (${suffix})`); - log.preview({ title: 'changelog', text: changelog }); } - if (config.isReleaseVersion) { + if (isReleaseVersion) { console.log(version); process.exit(0); } - if (config.isChangelog) { - console.log(changelog); - process.exit(0); - } - if (version) { config.setContext(parseVersion(version));