import { rm } from 'shelljs' ; import Tunnel from '../../src/Tunnel' ; param tunnel return { Promise } export function cleanup ( tunnel ) { if ( ! tunnel ) { return Promise . resolve ( ) ; } let error ; return tunnel . stop ( ) . catch ( err => { error = err ; } ) . then ( ( ) => { deleteTunnelFiles ( tunnel ) ; if ( error ) { throw error ; } } ) ; } /**
 * Deletes a tunnel's target install directory
 */ export function deleteTunnelFiles ( tunnel ) { const args = getDigdugArgs ( ) ; if ( ! tunnel || ! tunnel . directory || args . noClean ) { return ; } rm ( '-rf' , tunnel . directory ) ; } /**
 * Return command line args specific to digdug
 */ export function getDigdugArgs ( ) { return { noClean : ( < any > intern . config ) . noClean } ; }