diff --git a/lib/lifecycles/commit.js b/lib/lifecycles/commit.js index c273949be..968ea8b56 100644 --- a/lib/lifecycles/commit.js +++ b/lib/lifecycles/commit.js @@ -19,21 +19,37 @@ module.exports = function (args, newVersion) { function execCommit (args, newVersion) { var msg = 'committing %s' - var paths = [args.infile] - var verify = args.verify === false || args.n ? '--no-verify ' : '' + var paths = [] var toAdd = '' + + // only start with a pre-populated paths list when CHANGELOG processing is not skipped + if (!args.skip.changelog) { + paths = [args.infile] + toAdd += args.infile + } + + var verify = args.verify === false || args.n ? '--no-verify ' : '' // commit any of the config files that we've updated // the version # for. Object.keys(bump.getUpdatedConfigs()).forEach(function (p) { if (bump.getUpdatedConfigs()[p]) { - msg += ' and %s' paths.unshift(path.basename(p)) toAdd += ' ' + path.relative(process.cwd(), p) + + // account for multiple files in the output message + if (paths.length > 1) { + msg += ' and %s' + } } }) checkpoint(args, msg, paths) - return runExec(args, 'git add' + toAdd + ' ' + args.infile) + + if (args.skip.changelog && args.skip.bump && toAdd.length === 0) { + return Promise.resolve() + } + + return runExec(args, 'git add ' + toAdd) .then(() => { - return runExec(args, 'git commit ' + verify + (args.sign ? '-S ' : '') + (args.commitAll ? '' : (args.infile + toAdd)) + ' -m "' + formatCommitMessage(args.message, newVersion) + '"') + return runExec(args, 'git commit ' + verify + (args.sign ? '-S ' : '') + (args.commitAll ? '' : (toAdd)) + ' -m "' + formatCommitMessage(args.message, newVersion) + '"') }) } diff --git a/test.js b/test.js index 88126d430..adbf6b8e1 100644 --- a/test.js +++ b/test.js @@ -885,6 +885,16 @@ describe('standard-version', function () { }) describe('skip', () => { + it('can skip changelog generation when a changelog file is not present', function () { + writePackageJson('1.0.0') + + commit('feat: first commit') + return execCliAsync('--skip.changelog true') + .then(function () { + getPackageVersion().should.equal('1.1.0') + }) + }) + it('allows bump and changelog generation to be skipped', function () { let changelogContent = 'legacy header format\n' writePackageJson('1.0.0')