@@ -185,3 +185,28 @@ export function successMessage(
185185export function errorMessage ( error : Error | unknown , context : string ) : void {
186186 throw new Error ( `[error]: ${ context } failed: \n${ error } ` ) ;
187187}
188+
189+ /**
190+ * @description Run a command with its arguments and inherit stdio
191+ * @param command The command to run
192+ * @param args The arguments to pass to the command
193+ * @param interactiveMode Whether to run the command in interactive mode (inherit stdio)
194+ * @param shellMode Whether to run the command in shell mode
195+ */
196+ export async function runCommandAsync (
197+ command : string ,
198+ args : string [ ] ,
199+ interactiveMode : boolean ,
200+ shellMode : boolean ,
201+ ) : Promise < void > {
202+ await execa ( command , args , {
203+ stdio : interactiveMode ? "inherit" : [ "pipe" , "inherit" , "inherit" ] ,
204+ input : interactiveMode ? undefined : process . stdin , // Inherit input if in interactive mode
205+ shell : shellMode , // Use shell mode if specified
206+ env : process . env , // Inherit environment variables
207+ cleanup : true , // Cleanup resources after execution
208+ preferLocal : false , // Prefer global installation of task-master
209+ windowsHide : false , // Hide the console window on MS Windows
210+ buffer : false , // Disable output buffering
211+ } ) ;
212+ }
0 commit comments