@@ -174,7 +174,7 @@ function writeResult(result: Result): void {
174174async function main ( ) : Promise < void > {
175175 const commands = new Set ( [ "patch" , "minor" , "major" ] ) ;
176176 const result = parseArgs ( {
177- strict : true ,
177+ strict : false ,
178178 allowPositionals : true ,
179179 options : {
180180 all : { short : "a" , type : "boolean" } ,
@@ -188,7 +188,7 @@ async function main(): Promise<void> {
188188 base : { short : "b" , type : "string" } ,
189189 command : { short : "c" , type : "string" } ,
190190 replace : { short : "r" , type : "string" , multiple : true } ,
191- message : { short : "m" , type : "string" } ,
191+ message : { short : "m" , type : "string" , multiple : true } ,
192192 } ,
193193 } ) ;
194194 const args = result . values ;
@@ -270,9 +270,9 @@ async function main(): Promise<void> {
270270 const newVersion = incrementSemver ( baseVersion , level as SemverLevel ) ;
271271
272272 const replacements : Array < { re : RegExp , replacement : string } > = [ ] ;
273- if ( args . replace ) {
274- args . replace = ( Array . isArray ( args . replace ) ? args . replace : [ args . replace ] as Array < string > ) ;
275- for ( const replaceStr of args . replace ) {
273+ if ( args . replace ?. length ) {
274+ const replace = args . replace . filter ( arg => typeof arg === " string" ) ;
275+ for ( const replaceStr of replace ) {
276276 let [ _ , re , replacement , flags ] = ( / ^ s # ( .+ ?) # ( .+ ?) # ( .* ) $ / . exec ( replaceStr ) || [ ] ) ;
277277
278278 if ( ! re || ! replacement ) {
@@ -304,12 +304,12 @@ async function main(): Promise<void> {
304304 }
305305 }
306306
307- if ( args . command ) {
307+ if ( typeof args . command === "string" ) {
308308 writeResult ( await nanoSpawn ( args . command , [ ] , { shell : true } ) ) ;
309309 }
310310 if ( args . gitless ) return ; // nothing else to do
311311
312- const msg = args . message ;
312+ const msgs = ( args . message || [ ] ) . filter ( msg => typeof msg === "string" ) ;
313313 const tagName = args [ "prefix" ] ? `v${ newVersion } ` : newVersion ;
314314
315315 // check if base tag exists
@@ -344,7 +344,7 @@ async function main(): Promise<void> {
344344 }
345345
346346 // create commit
347- const commitMsg = joinStrings ( [ tagName , msg , changelog ] . filter ( Boolean ) , "\n\n" ) ;
347+ const commitMsg = joinStrings ( [ tagName , ... msgs , changelog ] , "\n\n" ) ;
348348 if ( args . all ) {
349349 writeResult ( await nanoSpawn ( "git" , [ "commit" , "-a" , "--allow-empty" , "-F" , "-" ] , { stdin : { string : commitMsg } } ) ) ;
350350 } else {
@@ -358,7 +358,7 @@ async function main(): Promise<void> {
358358 }
359359
360360 // create tag
361- const tagMsg = joinStrings ( [ msg , changelog ] . filter ( Boolean ) , "\n\n" ) ;
361+ const tagMsg = joinStrings ( [ ... msgs , changelog ] , "\n\n" ) ;
362362 // adding explicit -a here seems to make git no longer sign the tag
363363 writeResult ( await nanoSpawn ( "git" , [ "tag" , "-f" , "-F" , "-" , tagName ] , { stdin : { string : tagMsg } } ) ) ;
364364}
0 commit comments