import { ChildProcess } from "child_process" ; export async function onExit ( childProcess , message ? ) { return new Promise ( ( resolve , reject ) => { childProcess . once ( 'close' , ( code , signal ) => { if ( code === 0 || ( code === null && signal === "SIGTERM" ) ) { resolve ( undefined ) ; } else { reject ( new Error ( message ? message : `Exit with error code ${ code }` ) ) ; } } ) ; childProcess . once ( 'error' , ( err ) => { reject ( new Error ( message ? message : err . message ) ) ; } ) ; } ) ; }