import { getLodestarCli } from "../../src/cli" ; export function getLodestarCliTestRunner ( ) { return async < T = any > ( arg , context ? ) : Promise < T > => { return new Promise ( ( resolve , reject ) => { const lodestar = getLodestarCli ( ) ; lodestar . onFinishCommand ( ( result ) => { resolve ( result ) ; } ) . fail ( ( msg , err ) => { if ( err !== undefined ) reject ( err ) ; else if ( msg ) reject ( Error ( msg ) ) ; else reject ( Error ( "Unknown error" ) ) ; } ) . help ( false ) . exitProcess ( false ) . parse ( Array . isArray ( arg ) ? arg . join ( " " ) : arg , context ) ; } ) ; } ; }