Skip to content

Commit

Permalink
feat(options): add the ability to skip bump/changelog phase by using …
Browse files Browse the repository at this point in the history
…--skip-bump-and-changelog option, and to skip the commit/tag/push phase by using --skip-commit option

closes #157
  • Loading branch information
denouche committed Feb 23, 2017
1 parent d0d71a5 commit fc95812
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 21 deletions.
12 changes: 12 additions & 0 deletions command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 3 additions & 1 deletion defaults.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@
"noVerify": false,
"commitAll": false,
"silent": false,
"tagPrefix": "v"
"tagPrefix": "v",
"skipCommit": false,
"skipBumpAndChangelog": false
}
53 changes: 33 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}

/**
Expand Down

0 comments on commit fc95812

Please sign in to comment.