Skip to content

Commit 709dae1

Browse files
tmcwstevemao
authored andcommitted
fix: recommend --tag prerelease for npm publish of prereleases (#196)
The `--tag` argument to npm publish allows you to publish a prerelease without the prerelease assuming the 'latest' tag and causing users to download the prerelease by default. Instead, we recommend `--tag prerelease` by default when `--prerelease` is set in the `standard-version` call, so to install a prerelease version of the module, users will install `module@foo` or specify the exact version of the prerelease version. Fixes #183
1 parent 958daf4 commit 709dae1

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/lifecycles/tag.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function execTag (newVersion, pkgPrivate, args) {
2828
.then(() => {
2929
var message = 'git push --follow-tags origin master'
3030
if (pkgPrivate !== true) message += '; npm publish'
31+
if (args.prerelease !== undefined) message += ' --tag prerelease'
3132

3233
checkpoint(args, 'Run `%s` to publish', [message], chalk.blue(figures.info))
3334
})

test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,14 @@ describe('cli', function () {
360360
getPackageVersion().should.equal('1.1.0-0')
361361
})
362362
})
363+
364+
it('advises use of --tag prerelease for publishing to npm', function () {
365+
writePackageJson('1.0.0')
366+
fs.writeFileSync('CHANGELOG.md', 'legacy header format<a name="1.0.0">\n', 'utf-8')
367+
368+
commit('feat: first commit')
369+
execCli('--prerelease').stdout.should.include('--tag prerelease')
370+
})
363371
})
364372

365373
describe('manual-release', function () {

0 commit comments

Comments
 (0)