Repository: conventional-changelog/standard-version
Pull request #180 (2017-05-25 06:54:11)

Release as exact version

coveralls: 
[![Coverage Status](https://coveralls.io/builds/11682562/badge)](https://coveralls.io/builds/11682562)

Coverage remained the same at 100.0% when pulling **a8379b18f9c27546e0ac62c216502f42da36cc92 on feature/specify-version** into **0d1fb38de6046d5a96d2006013e2b90aed2834ae on master**.

bcoe: @stevemao at some point in the last few days, it looks like there's been a regression specifically on Windows; I see this error on the mocha update too:

`handles commit messages longer than 80 characters`

I think one of us will need to spin up a VM and test things potentially.

Patch:
diff --git a/README.md b/README.md
index 7d28fe3..396ff45 100644
--- a/README.md
+++ b/README.md
@@ -129,6 +129,8 @@ you would like your next release to be a `minor`. Simply do:
 ```bash
 # npm run script
 npm run release -- --release-as minor
+# Or
+npm run release -- --release-as 1.1.0
 ```
 
 you will get version `1.1.0` rather than the auto generated version `1.0.1`.
diff --git a/command.js b/command.js
index 60bdfd0..cbbf45d 100755
--- a/command.js
+++ b/command.js
@@ -7,7 +7,6 @@ module.exports = require('yargs')
     describe: 'Specify the release type manually (like npm version <major|minor|patch>)',
     requiresArg: true,
     string: true,
-    choices: ['major', 'minor', 'patch'],
     global: true
   })
   .option('prerelease', {
diff --git a/index.js b/index.js
index c7aa5ca..e6a7870 100755
--- a/index.js
+++ b/index.js
@@ -27,7 +27,7 @@ module.exports = function standardVersion (argv, done) {
 
     if (!args.firstRelease) {
       var releaseType = getReleaseType(args.prerelease, release.releaseType, pkg.version)
-      newVersion = semver.inc(pkg.version, releaseType, args.prerelease)
+      newVersion = semver.valid(releaseType) || semver.inc(pkg.version, releaseType, args.prerelease)
       updateConfigs(args, newVersion)
     } else {
       checkpoint(args, 'skip version bump on first release', [], chalk.red(figures.cross))


Test patch:
diff --git a/test.js b/test.js
index af217bc..995868b 100644
--- a/test.js
+++ b/test.js
@@ -290,6 +290,34 @@ describe('cli', function () {
       })
     })
 
+    describe('release-as-exact', function () {
+      it('releases as v100.0.0', function () {
+        var originVer = '1.0.0'
+        writePackageJson(originVer)
+        fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
+
+        commit('fix: first commit')
+
+        return execCliAsync('--release-as v100.0.0')
+          .then(function () {
+            getPackageVersion().should.equal('100.0.0')
+          })
+      })
+
+      it('releases as 200.0.0-amazing', function () {
+        var originVer = '1.0.0'
+        writePackageJson(originVer)
+        fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
+
+        commit('fix: first commit')
+
+        return execCliAsync('--release-as 200.0.0-amazing')
+          .then(function () {
+            getPackageVersion().should.equal('200.0.0-amazing')
+          })
+      })
+    })
+
     it('creates a prerelease with a new minor version after two prerelease patches', function () {
       writePackageJson('1.0.0')
       fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')