diff --git a/lib/package.js b/lib/package.js index 89fdd08..da3e6d1 100644 --- a/lib/package.js +++ b/lib/package.js @@ -52,6 +52,10 @@ exports.calculateNewVersion = function (options) { options = options || {}; return exports.getUserPackage() .then(function (userPackage) { + if (!userPackage.version) { + return null; + } + var split = userPackage.version.split('.'); if (options.major) { diff --git a/lib/writer.js b/lib/writer.js index 614bc31..50fed5d 100644 --- a/lib/writer.js +++ b/lib/writer.js @@ -42,7 +42,11 @@ exports.markdown = function (version, commits, options) { heading = '####'; } - heading += ' ' + version + ' (' + date + ')'; + if (version) { + heading += ' ' + version + ' (' + date + ')'; + } else { + heading += ' ' + date; + } content.push(heading); content.push(''); diff --git a/test/package.test.js b/test/package.test.js index 42c3257..f9ae814 100644 --- a/test/package.test.js +++ b/test/package.test.js @@ -148,6 +148,16 @@ describe('package', function () { }); }); + it('returns null if no version is specified', function () { + Package.getUserPackage.restore(); + Sinon.stub(Package, 'getUserPackage').returns(Bluebird.resolve({ version: '' })); + + return Package.calculateNewVersion() + .then(function (version) { + Expect(version).to.be.null; + }); + }); + }); }); diff --git a/test/writer.test.js b/test/writer.test.js index 6a364c0..22ed148 100644 --- a/test/writer.test.js +++ b/test/writer.test.js @@ -43,6 +43,17 @@ describe('writer', function () { }); }); + it('keeps only the date if no version is specified', function () { + var options = { major: true }; + + return Writer.markdown(false, [], options) + .then(function (changelog) { + var heading = changelog.split('\n')[0]; + + Expect(heading).to.equal('## ' + new Date().toJSON().slice(0, 10)); + }); + }); + it('flushes out a commit type with its full name', function () { var commits = [ { type: 'feat', category: 'testing', subject: 'did some testing', hash: '1234567890' }