Repository: conventional-changelog/standard-version
Pull request #296 (2019-01-16 22:35:42)

fix: no --tag prerelease for private module
fixes: #294

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

Coverage remained the same at 100.0% when pulling **efc815e0240e51105754bd2688e1433ee1ffaef8 on whyvez:fix-294** into **cbedc52758e3fb0210046e5556244217b8ebd7a8 on conventional-changelog:master**.

stevemao: Otherwise LGTM :)

Patch:
diff --git a/README.md b/README.md
index ce7e556..f5ff0f7 100644
--- a/README.md
+++ b/README.md
@@ -308,7 +308,7 @@ Tell your users that you adhere to the Conventional Commits specification:
 
 [`semantic-release`](https://github.com/semantic-release/semantic-release) is a fully automated library/system for versioning, changelog generation, git tagging, and publishing to the npm registry.
 
-`standard-version` is different because it handles the versioning, changelog generation, and git tagging for you **without** automatic pushing (to GitHub) or publishing (to an npm registry). Use of `standard-version` only affects your local git repo - it doesn't affect remote resources at all. After you run `standard-version`, you still have to ability to review things and correct mistakes if you want to.
+`standard-version` is different because it handles the versioning, changelog generation, and git tagging for you **without** automatic pushing (to GitHub) or publishing (to an npm registry). Use of `standard-version` only affects your local git repo - it doesn't affect remote resources at all. After you run `standard-version`, you still have the ability to review things and correct mistakes if you want to.
 
 They are both based on the same foundation of structured commit messages (using [Angular format](https://github.com/bcoe/conventional-changelog-standard/blob/master/convention.md)), but `standard-version` is a good choice for folks who are not yet comfortable letting publishes go out automatically. In this way, you can view `standard-version` as an incremental step to adopting `semantic-release`.
 
diff --git a/lib/lifecycles/tag.js b/lib/lifecycles/tag.js
index fc41acb..f59aedf 100644
--- a/lib/lifecycles/tag.js
+++ b/lib/lifecycles/tag.js
@@ -27,12 +27,14 @@ function execTag (newVersion, pkgPrivate, args) {
   return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"')
     .then(() => {
       var message = 'git push --follow-tags origin master'
-      if (pkgPrivate !== true) message += ' && npm publish'
-      if (args.prerelease !== undefined) {
-        if (args.prerelease === '') {
-          message += ' --tag prerelease'
-        } else {
-          message += ' --tag ' + args.prerelease
+      if (pkgPrivate !== true) {
+        message += ' && npm publish'
+        if (args.prerelease !== undefined) {
+          if (args.prerelease === '') {
+            message += ' --tag prerelease'
+          } else {
+            message += ' --tag ' + args.prerelease
+          }
         }
       }
 
diff --git a/package.json b/package.json
index 7de0690..4e840f1 100644
--- a/package.json
+++ b/package.json
@@ -44,6 +44,7 @@
     "dotgitignore": "^1.0.3",
     "figures": "^2.0.0",
     "fs-access": "^1.0.0",
+    "git-semver-tags": "^2.0.2",
     "semver": "^5.2.0",
     "yargs": "^12.0.2"
   },


Test patch:
diff --git a/test.js b/test.js
index ec891f9..158e181 100644
--- a/test.js
+++ b/test.js
@@ -440,6 +440,14 @@ describe('cli', function () {
       commit('feat: first commit')
       execCli('--prerelease alpha').stdout.should.include('--tag alpha')
     })
+
+    it('does not advise use of --tag prerelease for private modules', function () {
+      writePackageJson('1.0.0', { private: true })
+      fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
+
+      commit('feat: first commit')
+      execCli('--prerelease').stdout.should.not.include('--tag prerelease')
+    })
   })
 
   describe('manual-release', function () {