import { spawnSync } from 'child_process' ; import chalk from 'chalk' ; /**
 * Executes the function passed as an argument and properly shuts down the node environment.
 *
 * Any uncaught error or promise rejection will be printed out in the console.
 */ export const runAndHandleErrors = ( fn ) => { try { fn ( ) . then ( ( ) => process . exit ( 0 ) ) . catch ( ( error ) => { cliPrint . error ( error ) ; process . exit ( 1 ) ; } ) ; } catch ( error ) { cliPrint . error ( '' + error ) ; process . exit ( 1 ) ; } } ; /**
 * Run the command passed as an argument in the current shell and stream the output of the command in the CLI.
 */ export const runShellCommand = ( command ) => { cliPrint . info ( command ) ; spawnSync ( command , { shell : true , stdio : 'inherit' , } ) ; } ; export const cliPrint = { info : ( text ) => console . log ( chalk . bold . white ( text ) ) , warning : ( text ) => console . log ( chalk . bold . hex ( '#FFA500' ) ( text ) ) , error : ( text ) => console . log ( chalk . bold . red ( text ) ) , } ;