@@ -72,6 +72,29 @@ export async function versionBump(arg: (VersionBumpOptions) | string = {}): Prom
7272 // Update the version number in all files
7373 await updateFiles ( operation )
7474
75+ if ( operation . options . install ) {
76+ const { detect } = await import ( 'package-manager-detector/detect' )
77+ const pm = await detect ( )
78+ if ( ! pm ?. name ) {
79+ throw new Error ( 'Could not detect package manager, failed to run npm install' )
80+ }
81+
82+ const { COMMANDS , constructCommand } = await import ( 'package-manager-detector/commands' )
83+ const command = constructCommand ( COMMANDS [ pm . name ] . install , [ ] )
84+ if ( ! command ) {
85+ throw new Error ( 'Could not find install command for package manager' )
86+ }
87+ console . log ( symbols . info , 'Installing dependencies with' , `${ command . command } ${ command . args . join ( ' ' ) } ` )
88+ await x ( command . command , command . args , {
89+ throwOnError : true ,
90+ nodeOptions : {
91+ stdio : 'inherit' ,
92+ cwd : operation . options . cwd ,
93+ } ,
94+ } )
95+ console . log ( symbols . success , 'Dependencies installed' )
96+ }
97+
7598 if ( operation . options . execute ) {
7699 if ( typeof operation . options . execute === 'function' ) {
77100 await operation . options . execute ( operation )
@@ -117,6 +140,8 @@ function printSummary(operation: Operation) {
117140 console . log ( ` execute ${ c . bold ( typeof operation . options . execute === 'function' ? 'function' : operation . options . execute ) } ` )
118141 if ( operation . options . push )
119142 console . log ( ` push ${ c . cyan ( c . bold ( 'yes' ) ) } ` )
143+ if ( operation . options . install )
144+ console . log ( ` install ${ c . cyan ( c . bold ( 'yes' ) ) } ` )
120145 console . log ( )
121146 console . log ( ` from ${ c . bold ( operation . state . currentVersion ) } ` )
122147 console . log ( ` to ${ c . green ( c . bold ( operation . state . newVersion ) ) } ` )
0 commit comments