From 427b891ca6ffb77e632ccb33c6dedc68e1d78dcc Mon Sep 17 00:00:00 2001 From: Kristjan Broder Lund Date: Thu, 28 Mar 2019 19:27:09 +0000 Subject: [PATCH] fix: stop suggesting npm publish if package.json was not updated --- lib/lifecycles/tag.js | 3 ++- test.js | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/lifecycles/tag.js b/lib/lifecycles/tag.js index a7b40191d..59bd38cfd 100644 --- a/lib/lifecycles/tag.js +++ b/lib/lifecycles/tag.js @@ -1,3 +1,4 @@ +const bump = require('../lifecycles/bump') const chalk = require('chalk') const checkpoint = require('../checkpoint') const figures = require('figures') @@ -27,7 +28,7 @@ function execTag (newVersion, pkgPrivate, args) { return runExec(args, 'git tag ' + tagOption + args.tagPrefix + newVersion + ' -m "' + formatCommitMessage(args.message, newVersion) + '"') .then(() => { let message = 'git push --follow-tags origin master' - if (pkgPrivate !== true) { + if (pkgPrivate !== true && bump.getUpdatedConfigs()['package.json']) { message += ' && npm publish' if (args.prerelease !== undefined) { if (args.prerelease === '') { diff --git a/test.js b/test.js index 363d07f89..1b2fd9950 100644 --- a/test.js +++ b/test.js @@ -988,5 +988,12 @@ describe('standard-version', function () { output.stdout.should.include('v5.1.0') }) }) + + it('does not display `npm publish` if there is no package.json', function () { + shell.rm('package.json') + var result = execCli() + result.code.should.equal(0) + result.stdout.should.not.match(/npm publish/) + }) }) })