@@ -13,26 +13,31 @@ async function format(contents: object) {
1313class Versioner {
1414 localAndExtraModules : { [ name : string ] : string } = { } ;
1515 private noTest = false ;
16+ private tag = undefined ;
1617 noPublish = false ;
1718
1819 haibunPackageVersions: { [ dep : string ] : string } = { } ;
1920
2021 constructor ( private version : string ) {
2122 if ( ! version ) {
22- console . error ( `usage: ${ me } : <version> <extra modules> [--notest]` ) ;
23+ console . error ( `usage: ${ me } : <version> <extra modules> [--notest] [--tag=<tag>] [--nopublish] ` ) ;
2324 process . exit ( 1 ) ;
2425 }
25- extra . forEach ( ( e , i ) => {
26- if ( e === '--notest' ) {
26+ for ( let i = extra . length - 1 ; i >= 0 ; i -- ) {
27+ const e = extra [ i ] ;
28+ if ( e . startsWith ( '--tag=' ) ) {
29+ this . tag = e . split ( '=' ) [ 1 ] ;
30+ extra . splice ( i , 1 ) ;
31+ } else if ( e === '--notest' ) {
2732 this . noTest = true ;
2833 extra . splice ( i , 1 ) ;
2934 } else if ( e === '--nopublish' ) {
3035 this . noPublish = true ;
3136 extra . splice ( i , 1 ) ;
3237 } else if ( e . startsWith ( '-' ) ) {
33- throw Error ( `unknown option ${ e } ; use --notest or --nopublish` ) ;
38+ throw Error ( `unknown option ${ e } ; use --tag=<tag>, -- notest or --nopublish` ) ;
3439 }
35- } ) ;
40+ }
3641 }
3742
3843 async doVersion ( ) {
@@ -91,10 +96,14 @@ class Versioner {
9196 }
9297
9398 async npmPublish ( name : string , module : string ) {
99+ const publish = [ 'npm' , 'publish' ] ;
100+ if ( this . tag ) {
101+ publish . push ( '--tag' , this . tag ) ;
102+ }
94103 if ( this . noPublish ) {
95104 return ;
96105 }
97- await spawnCommand ( [ 'npm' , ' publish' ] , module ) . catch ( ( e ) => {
106+ await spawnCommand ( publish , module ) . catch ( ( e ) => {
98107 console . error ( `npm publish failed for ${ name } : ${ e } ` ) ;
99108 } ) ;
100109 }
0 commit comments