import { spawnSync , spawn , ChildProcessWithoutNullStreams } from 'child_process' ; export const runCommand = ( command ) => { console . log ( `Running command:\n${ command }` ) ; const result = spawnSync ( command , { shell : true , } ) ; if ( result . status !== 0 || result . error ) { throw new Error ( result . error ?. message ?? 'Command failed with non-zero status code' ) ; } return result . stdout . toString ( ) ; } ; export const runCommandInBackground = ( command ) => { console . log ( `Running background command:\n${ command }` ) ; return spawn ( command , { detached : true , shell : true , } ) ; } ; export const killBackgroundProcess = ( processToKill ) => { process . kill ( - processToKill . pid ! ) ; } ;