import { execSync , ExecSyncOptions } from 'child_process' ; import tracer from '../telemetry/tracer' ; export type GPExecSyncOptions = { printStdout ? : boolean ; } ; export function gpExecSync ( command , onError ? ) { try { if ( tracer . currentSpanId ) { return tracer . spanSync ( { name : 'execSync' , resource : 'gpExecSync' , meta : { command : command . command } , } , ( ) => { return gpExecSyncImpl ( command ) ; } ) ; } else { return gpExecSyncImpl ( command ) ; } } catch ( e ) { onError ?. ( e ) ; return Buffer . alloc ( 0 ) ; } } function gpExecSyncImpl ( command ) { const output = execSync ( command . command , { ... command . options , } ) ; if ( command . options ?. printStdout ) { console . log ( output . toString ( ) ) ; } return output ; }