@@ -11,10 +11,12 @@ const {execRead, execUnlessDry, logPromise} = require('../utils');
1111const push = async ( { cwd, dry, otp, packages, version, tag} ) => {
1212 const errors = [ ] ;
1313 const isPrerelease = semver . prerelease ( version ) ;
14+
15+ let resolvedTag = tag ;
1416 if ( tag === undefined ) {
1517 // No tag was provided. Default to `latest` for stable releases and `next`
1618 // for prereleases
17- tag = isPrerelease ? 'next' : 'latest' ;
19+ resolvedTag = isPrerelease ? 'next' : 'latest' ;
1820 } else if ( tag === 'latest' && isPrerelease ) {
1921 throw new Error ( 'The tag `latest` can only be used for stable versions.' ) ;
2022 }
@@ -26,7 +28,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
2628 const publishProject = async project => {
2729 try {
2830 const path = join ( cwd , 'build' , 'node_modules' , project ) ;
29- await execUnlessDry ( `npm publish --tag ${ tag } ${ twoFactorAuth } ` , {
31+ await execUnlessDry ( `npm publish --tag ${ resolvedTag } ${ twoFactorAuth } ` , {
3032 cwd : path ,
3133 dry,
3234 } ) ;
@@ -49,7 +51,7 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
4951 const status = JSON . parse (
5052 await execRead ( `npm info ${ project } dist-tags --json` )
5153 ) ;
52- const remoteVersion = status [ tag ] ;
54+ const remoteVersion = status [ resolvedTag ] ;
5355
5456 // Compare remote version to package.json version,
5557 // To better handle the case of pre-release versions.
@@ -62,7 +64,9 @@ const push = async ({cwd, dry, otp, packages, version, tag}) => {
6264
6365 // If we've just published a stable release,
6466 // Update the @next tag to also point to it (so @next doesn't lag behind).
65- if ( ! isPrerelease ) {
67+ // Skip this step if we have a manually specified tag.
68+ // This is an escape hatch for us to interleave alpha and stable releases.
69+ if ( tag === undefined && ! isPrerelease ) {
6670 await execUnlessDry (
6771 `npm dist-tag add ${ project } @${ packageVersion } next ${ twoFactorAuth } ` ,
6872 { cwd : path , dry}
0 commit comments