import { RedspotContext } from './context' ; export function resetRedspotContext ( ) { if ( RedspotContext . isCreated ( ) ) { const ctx = RedspotContext . getRedspotContext ( ) ; if ( ctx . environment !== undefined ) { const globalAsAny = global as any ; for ( const key of Object . keys ( ctx . environment ) ) { globalAsAny [ key ] = undefined ; } } const filesLoadedDuringConfig = ctx . getFilesLoadedDuringConfig ( ) ; filesLoadedDuringConfig . forEach ( unloadModule ) ; RedspotContext . deleteRedspotContext ( ) ; } unloadModule ( '../register' ) ; unloadModule ( './cli/cli' ) ; unloadModule ( './lib/redspot-lib' ) ; } function unloadModule ( path ) { try { delete require . cache [ require . resolve ( path ) ] ; } catch ( err ) { } }