From fc9581296eac83827b26918577272553917c5164 Mon Sep 17 00:00:00 2001 From: "antoine.leveugle" Date: Thu, 23 Feb 2017 09:53:54 +0100 Subject: [PATCH] feat(options): add the ability to skip bump/changelog phase by using --skip-bump-and-changelog option, and to skip the commit/tag/push phase by using --skip-commit option closes #157 --- command.js | 12 ++++++++++++ defaults.json | 4 +++- index.js | 53 ++++++++++++++++++++++++++++++++------------------- 3 files changed, 48 insertions(+), 21 deletions(-) diff --git a/command.js b/command.js index 60bdfd0fa..d86537f4d 100755 --- a/command.js +++ b/command.js @@ -70,6 +70,18 @@ module.exports = require('yargs') default: defaults.tagPrefix, global: true }) + .option('skip-commit', { + describe: 'Bypass the commit, tag and push to git phase. In another words just bump the version and create the changelog.', + type: 'boolean', + default: defaults.skipCommit, + global: true + }) + .option('skip-bump-and-changelog', { + describe: 'Bypass the bump and changelog generation phase. In another words, just commit, create the tag, and push to git.', + type: 'boolean', + default: defaults.skipBumpAndChangelog, + global: true + }) .version() .alias('version', 'v') .help() diff --git a/defaults.json b/defaults.json index 26ef43c73..10784c98b 100644 --- a/defaults.json +++ b/defaults.json @@ -6,5 +6,7 @@ "noVerify": false, "commitAll": false, "silent": false, - "tagPrefix": "v" + "tagPrefix": "v", + "skipCommit": false, + "skipBumpAndChangelog": false } diff --git a/index.js b/index.js index c7aa5ca09..4faa6e738 100755 --- a/index.js +++ b/index.js @@ -17,34 +17,47 @@ module.exports = function standardVersion (argv, done) { var defaults = require('./defaults') var args = objectAssign({}, defaults, argv) - bumpVersion(args.releaseAs, function (err, release) { - if (err) { - printError(args, err.message) - return done(err) - } - - var newVersion = pkg.version - - if (!args.firstRelease) { - var releaseType = getReleaseType(args.prerelease, release.releaseType, pkg.version) - newVersion = semver.inc(pkg.version, releaseType, args.prerelease) - updateConfigs(args, newVersion) - } else { - checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross)) - } - - outputChangelog(args, function (err) { + if (argv.skipBumpAndChangelog) { + updateConfigs(args, pkg.version) + commitIfNeeded(argv, args, pkg.version, pkg, done) + } else { + bumpVersion(args.releaseAs, function (err, release) { if (err) { + printError(args, err.message) return done(err) } - commit(args, newVersion, function (err) { + + var newVersion = pkg.version + + if (!args.firstRelease) { + var releaseType = getReleaseType(args.prerelease, release.releaseType, pkg.version) + newVersion = semver.inc(pkg.version, releaseType, args.prerelease) + updateConfigs(args, newVersion) + } else { + checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross)) + } + + outputChangelog(args, function (err) { if (err) { return done(err) } - return tag(newVersion, pkg.private, args, done) + commitIfNeeded(argv, args, newVersion, pkg, done) }) }) - }) + } +} + +function commitIfNeeded (argv, args, newVersion, pkg, cb) { + if (argv.skipCommit) { + cb() + } else { + commit(args, newVersion, function (err) { + if (err) { + return cb(err) + } + return tag(newVersion, pkg.private, args, cb) + }) + } } /**