diff --git a/index.js b/index.js index 8faf1e343..9361ac226 100755 --- a/index.js +++ b/index.js @@ -148,16 +148,16 @@ function tag (newVersion, argv) { } checkpoint('tagging release %s', [newVersion]) exec('git tag ' + tagOption + 'v' + newVersion + ' -m "' + formatCommitMessage(argv.message, newVersion) + '"', function (err, stdout, stderr) { + var message = 'git push --follow-tags origin master' var errMessage = null if (err) errMessage = err.message if (stderr) errMessage = stderr + if (pkg.private !== true) message += '; npm publish' if (errMessage) { console.log(chalk.red(errMessage)) process.exit(1) } else { - checkpoint('Run `%s` to publish', [ - 'git push --follow-tags origin master; npm publish' - ], chalk.blue(figures.info)) + checkpoint('Run `%s` to publish', [message], chalk.blue(figures.info)) } }) } diff --git a/test.js b/test.js index 19316a139..b3f04f892 100644 --- a/test.js +++ b/test.js @@ -2,6 +2,7 @@ 'use strict' +var extend = Object.assign || require('util')._extend var shell = require('shelljs') var fs = require('fs') var path = require('path') @@ -18,10 +19,10 @@ function execCli (argString) { return shell.exec('node ' + cliPath + (argString != null ? ' ' + argString : '')) } -function writePackageJson (version) { - fs.writeFileSync('package.json', JSON.stringify({ - version: version - }), 'utf-8') +function writePackageJson (version, option) { + option = option || {} + var pkg = extend(option, {version: version}) + fs.writeFileSync('package.json', JSON.stringify(pkg), 'utf-8') } function writeGitPreCommitHook () { @@ -197,4 +198,12 @@ describe('cli', function () { commit('feat: second commit') execCli('-n').code.should.equal(0) }) + + it('does not display `npm publish` if the package is private', function () { + writePackageJson('1.0.0', {private: true}) + + var result = execCli() + result.code.should.equal(0) + result.stdout.should.not.match(/npm publish/) + }) })